From 374a43b1d7fa727298657fd24deacd3982f12fcd Mon Sep 17 00:00:00 2001 From: mirsella Date: Mon, 11 Dec 2023 11:21:59 +0100 Subject: [PATCH] template: build.rs dont write file if no change made --- template/build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/template/build.rs b/template/build.rs index 2792913..b6a19a0 100644 --- a/template/build.rs +++ b/template/build.rs @@ -7,7 +7,10 @@ fn replace_in_file(file_path: &PathBuf, old: &str, new: &str) -> io::Result<()> let mut contents = String::new(); File::open(file_path)?.read_to_string(&mut contents)?; let new_contents = contents.replace(old, new); - fs::write(file_path, new_contents)?; + if contents != new_contents { + println!("Updating {}", file_path.display()); + fs::write(file_path, new_contents)?; + } Ok(()) }