Skip to content

Commit

Permalink
Add a change detection delimiter msg to stderr in --watch (#96)
Browse files Browse the repository at this point in the history
* Add a change detection msg to stderr in --watch

* Make clippy happy
  • Loading branch information
mpizenberg authored Sep 16, 2021
1 parent 46c4f39 commit 3cee5ea
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")?;
}
Expand Down

0 comments on commit 3cee5ea

Please sign in to comment.