diff --git a/cli/tools/bench/mod.rs b/cli/tools/bench/mod.rs index 272d063355..1d49fa061d 100644 --- a/cli/tools/bench/mod.rs +++ b/cli/tools/bench/mod.rs @@ -486,6 +486,7 @@ pub async fn run_benchmarks_with_watch( ), move |flags, watcher_communicator, changed_paths| { let bench_flags = bench_flags.clone(); + watcher_communicator.show_path_changed(changed_paths.clone()); Ok(async move { let factory = CliFactory::from_flags_for_watcher( flags, diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index 56b1632cfb..2221c0da97 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -83,6 +83,7 @@ pub async fn format( file_watcher::PrintConfig::new("Fmt", !watch_flags.no_clear_screen), move |flags, watcher_communicator, changed_paths| { let fmt_flags = fmt_flags.clone(); + watcher_communicator.show_path_changed(changed_paths.clone()); Ok(async move { let factory = CliFactory::from_flags(flags); let cli_options = factory.cli_options()?; diff --git a/cli/tools/lint/mod.rs b/cli/tools/lint/mod.rs index 36f1cc0491..a9c2d01528 100644 --- a/cli/tools/lint/mod.rs +++ b/cli/tools/lint/mod.rs @@ -80,6 +80,7 @@ pub async fn lint( file_watcher::PrintConfig::new("Lint", !watch_flags.no_clear_screen), move |flags, watcher_communicator, changed_paths| { let lint_flags = lint_flags.clone(); + watcher_communicator.show_path_changed(changed_paths.clone()); Ok(async move { let factory = CliFactory::from_flags(flags); let cli_options = factory.cli_options()?; diff --git a/cli/tools/run/mod.rs b/cli/tools/run/mod.rs index bebb3f5881..8fab544eca 100644 --- a/cli/tools/run/mod.rs +++ b/cli/tools/run/mod.rs @@ -124,7 +124,8 @@ async fn run_with_watch( !watch_flags.no_clear_screen, ), WatcherRestartMode::Automatic, - move |flags, watcher_communicator, _changed_paths| { + move |flags, watcher_communicator, changed_paths| { + watcher_communicator.show_path_changed(changed_paths.clone()); Ok(async move { let factory = CliFactory::from_flags_for_watcher( flags, diff --git a/cli/tools/serve.rs b/cli/tools/serve.rs index e3f9e94f8e..d7989140ae 100644 --- a/cli/tools/serve.rs +++ b/cli/tools/serve.rs @@ -151,7 +151,8 @@ async fn serve_with_watch( !watch_flags.no_clear_screen, ), WatcherRestartMode::Automatic, - move |flags, watcher_communicator, _changed_paths| { + move |flags, watcher_communicator, changed_paths| { + watcher_communicator.show_path_changed(changed_paths.clone()); Ok(async move { let factory = CliFactory::from_flags_for_watcher( flags, diff --git a/cli/tools/test/mod.rs b/cli/tools/test/mod.rs index 966b0d285a..6357ebcae2 100644 --- a/cli/tools/test/mod.rs +++ b/cli/tools/test/mod.rs @@ -1661,6 +1661,7 @@ pub async fn run_tests_with_watch( ), move |flags, watcher_communicator, changed_paths| { let test_flags = test_flags.clone(); + watcher_communicator.show_path_changed(changed_paths.clone()); Ok(async move { let factory = CliFactory::from_flags_for_watcher( flags, diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index 21ea95e067..eb3fb8c602 100644 --- a/cli/util/file_watcher.rs +++ b/cli/util/file_watcher.rs @@ -127,19 +127,12 @@ impl PrintConfig { } } -fn create_print_after_restart_fn( - banner: &'static str, - clear_screen: bool, -) -> impl Fn() { +fn create_print_after_restart_fn(clear_screen: bool) -> impl Fn() { move || { #[allow(clippy::print_stderr)] if clear_screen && std::io::stderr().is_terminal() { eprint!("{}", CLEAR_SCREEN); } - info!( - "{} File change detected! Restarting!", - colors::intense_blue(banner), - ); } } @@ -187,7 +180,15 @@ impl WatcherCommunicator { } pub fn print(&self, msg: String) { - log::info!("{} {}", self.banner, msg); + log::info!("{} {}", self.banner, colors::gray(msg)); + } + + pub fn show_path_changed(&self, changed_paths: Option>) { + if let Some(paths) = changed_paths { + self.print( + format!("Restarting! File change detected: {:?}", paths[0]).to_string(), + ) + } } } @@ -263,7 +264,7 @@ where clear_screen, } = print_config; - let print_after_restart = create_print_after_restart_fn(banner, clear_screen); + let print_after_restart = create_print_after_restart_fn(clear_screen); let watcher_communicator = Arc::new(WatcherCommunicator { paths_to_watch_tx: paths_to_watch_tx.clone(), changed_paths_rx: changed_paths_rx.resubscribe(), diff --git a/tests/integration/watcher_tests.rs b/tests/integration/watcher_tests.rs index e8f264632d..055e46af9c 100644 --- a/tests/integration/watcher_tests.rs +++ b/tests/integration/watcher_tests.rs @@ -55,7 +55,7 @@ where let mut str = String::new(); while let Some(t) = next_line(stderr_lines).await { let t = util::strip_ansi_codes(&t); - if t.starts_with("Watcher File change detected") { + if t.starts_with("Watcher Restarting! File change detected") { continue; } if t.starts_with("Watcher") {