Skip to content

Commit 9890c24

Browse files
authored
Merge pull request #41 from dani0854/only-write-on-change
2 parents 2de904f + cf192fa commit 9890c24

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cmd/root.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,11 @@ func processInput(inputName string, inputBytes []byte, config *lib.Config) (form
8787
}
8888
return true
8989
} else if writeFlag {
90-
err := os.WriteFile(inputName, []byte(formattedContent), 0644)
91-
if err != nil {
92-
log.Fatalf("Failed to write to file %s: %v", inputName, err)
90+
if originalContent != formattedContent {
91+
err := os.WriteFile(inputName, []byte(formattedContent), 0644)
92+
if err != nil {
93+
log.Fatalf("Failed to write to file %s: %v", inputName, err)
94+
}
9395
}
9496
} else {
9597
_, err := os.Stdout.Write([]byte(formattedContent))

0 commit comments

Comments
 (0)