mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 12:37:45 +00:00
Merge pull request #65 from kamadorueda/kamadorueda
feat: write if changed
This commit is contained in:
commit
85365a5bec
1 changed files with 8 additions and 2 deletions
|
@ -28,9 +28,15 @@ pub fn file(
|
|||
use std::io::Write;
|
||||
|
||||
let input = std::fs::read_to_string(&path)?;
|
||||
let output = crate::format::string(config, path.clone(), input);
|
||||
let input_clone = input.clone();
|
||||
let input_bytes = input_clone.as_bytes();
|
||||
|
||||
std::fs::File::create(path)?.write_all(output.as_bytes())?;
|
||||
let output = crate::format::string(config, path.clone(), input);
|
||||
let output_bytes = output.as_bytes();
|
||||
|
||||
if input_bytes != output_bytes {
|
||||
std::fs::File::create(path)?.write_all(output_bytes)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue