From 3cee5ea598e36a6ed3518eac5c05a8d78fce1892 Mon Sep 17 00:00:00 2001 From: Matthieu Pizenberg Date: Thu, 16 Sep 2021 21:42:56 +0200 Subject: [PATCH] Add a change detection delimiter msg to stderr in --watch (#96) * Add a change detection msg to stderr in --watch * Make clippy happy --- src/project.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/project.rs b/src/project.rs index b4620aa..8195922 100644 --- a/src/project.rs +++ b/src/project.rs @@ -131,6 +131,29 @@ impl Project { // Update the current project since dependencies or source directories may have change. *self = new_project; + // Log to stderr that a change was detected. + let relative_path = match path { + None => None, + Some(p) => Some(pathdiff::diff_paths(p, &self.root_directory).context( + format!( + "Could not get path {} relative to path {}", + p.display(), + self.root_directory.display() + ), + )?), + }; + let detection_msg = format!( + "Change detected in {}", + relative_path + .unwrap_or_else(|| PathBuf::from("unknown file")) + .display() + ); + log::error!( + "\n\n\n\n{}\n{}\n\n\n\n", + detection_msg, + "=".repeat(detection_msg.len()) + ); + // Call the function to execute passed as argument. call_back(self).context("Subsequent run in watch mode")?; }