Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear console before running command in exec -w #10983

Merged
merged 1 commit into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions bin/exec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,17 @@ module Command_to_exec = struct

(* Run the command, first (re)building the program which the command is
invoking *)
let build_and_run_in_child_process ~root { get_env_and_build_if_necessary; prog; args } =
let build_and_run_in_child_process
~root
~config
{ get_env_and_build_if_necessary; prog; args }
=
get_env_and_build_if_necessary prog
|> Fiber.map
~f:(Result.map ~f:(fun { path; env } -> spawn_process ~root ~args ~env path))
~f:
(Result.map ~f:(fun { path; env } ->
Scheduler.maybe_clear_screen ~details_hum:[] config;
spawn_process ~root ~args ~env path))
;;
end

Expand Down Expand Up @@ -144,18 +151,18 @@ module Watch = struct

(* Kills the currently running process, then runs the given command after
(re)building the program which it will invoke *)
let run ~root state ~command_to_exec =
let run ~root ~config state ~command_to_exec =
let open Fiber.O in
let* () = Fiber.return () in
let* () = kill_currently_running_process state in
let* command_to_exec = command_to_exec () in
Command_to_exec.build_and_run_in_child_process ~root command_to_exec
Command_to_exec.build_and_run_in_child_process ~root ~config command_to_exec
>>| Result.map ~f:(fun pid -> state.currently_running_pid := Some pid)
;;

let loop ~root ~command_to_exec =
let loop ~root ~config ~command_to_exec =
let state = init_state () in
Scheduler.Run.poll (run ~root state ~command_to_exec)
Scheduler.Run.poll (run ~root ~config state ~command_to_exec)
;;
end

Expand Down Expand Up @@ -328,7 +335,7 @@ module Exec_context = struct
; args
}
in
Watch.loop ~root:(Common.root common) ~command_to_exec
Watch.loop ~root:(Common.root common) ~config ~command_to_exec
;;
end

Expand Down
Loading