From d0087f8c74db05d07549ce5b6ede06ff0afde86a Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sat, 23 Dec 2023 12:23:54 +0100 Subject: [PATCH 1/2] Write files only if modified --- src/cli/main.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cli/main.rs b/src/cli/main.rs index 4c19a428..5295ab1d 100644 --- a/src/cli/main.rs +++ b/src/cli/main.rs @@ -180,8 +180,10 @@ fn format_file( None => Ok(FormatResult::Complete), } } else { - fs::write(path, formatted_contents) - .with_context(|| format!("could not write to {}", path.display()))?; + if formatted_contents != contents { + fs::write(path, formatted_contents) + .with_context(|| format!("could not write to {}", path.display()))?; + } Ok(FormatResult::Complete) } } From 453f75e303b4bcf2cd4be543eefdb493bda15d0b Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sat, 23 Dec 2023 12:25:29 +0100 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb7c209b..93a8d806 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed handling of floor division (`//`) syntax when only Luau FFlag is enabled - Fixed missing space when table is inside of Luau interpolated string expression (`{{` is invalid syntax) +- The CLI tool will now only write files if the contents differ, and not modify if no change (#827) ## [0.19.1] - 2023-11-15