diff options
author | HasanAlrimawi <141642411+HasanAlrimawi@users.noreply.github.com> | 2024-11-16 16:59:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-16 15:59:31 +0100 |
commit | abf06eb87f10ebed93b39948213dccfe086bd0fa (patch) | |
tree | f67a1d5f6f0ba8ec7ff666f1029fa225978b242c /cli/util | |
parent | 768c5ea2bb2a927455577a29f0761425593aea98 (diff) |
feat(watch): log which file changed on HMR or watch change (#25801)
Closes #25504
Diffstat (limited to 'cli/util')
-rw-r--r-- | cli/util/file_watcher.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/cli/util/file_watcher.rs b/cli/util/file_watcher.rs index 21ea95e06..eb3fb8c60 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<Vec<PathBuf>>) { + 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(), |