We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 4557953 + 9e37c66 commit 938be77Copy full SHA for 938be77
1 file changed
cmd/hclfmt/main.go
@@ -106,6 +106,7 @@ func processFiles() error {
106
107
func processFile(fn string, in *os.File) error {
108
var err error
109
+ var hasLocalChanges bool = false
110
if in == nil {
111
in, err = os.Open(fn)
112
if err != nil {
@@ -131,10 +132,15 @@ func processFile(fn string, in *os.File) error {
131
132
133
if !bytes.Equal(inSrc, outSrc) {
134
changed = append(changed, fn)
135
+ hasLocalChanges = true
136
}
137
138
if *overwrite {
- return ioutil.WriteFile(fn, outSrc, 0644)
139
+ if hasLocalChanges {
140
+ return ioutil.WriteFile(fn, outSrc, 0644)
141
+ } else {
142
+ return nil
143
+ }
144
145
146
_, err = os.Stdout.Write(outSrc)
0 commit comments