Skip to content

Commit

Permalink
template: build.rs dont write file if no change made
Browse files Browse the repository at this point in the history
  • Loading branch information
mirsella committed Dec 11, 2023
1 parent dd0c5e0 commit 374a43b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion template/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down

0 comments on commit 374a43b

Please sign in to comment.