dont write to the file if the contents did not differ from formatted

This commit is contained in:
Jakub Doka 2024-10-27 18:56:29 +01:00
parent 5c82623db9
commit 849e842336
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143

View file

@ -74,7 +74,7 @@ pub fn run_compiler(root_file: &str, options: Options, out: &mut Vec<u8>) -> std
fn format_ast(ast: parser::Ast) -> std::io::Result<()> {
let mut output = String::new();
write!(output, "{ast}").unwrap();
if ast.file.deref() != output.as_str() {
if ast.file.deref().trim() != output.as_str().trim() {
std::fs::write(&*ast.path, output)?;
}
Ok(())