Skip to content

Commit

Permalink
add byte check before and after file is formatted (#1637)
Browse files Browse the repository at this point in the history
  • Loading branch information
hohobilly authored Aug 9, 2023
1 parent 27b27bd commit f05ccdc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions format/format.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package format

import (
"bytes"
"fmt"
"os"
"path/filepath"
Expand Down Expand Up @@ -98,6 +99,10 @@ func (f *Format) format(path string) error {
if err != nil {
return err
}
if bytes.Equal(contents, formatted) {
// Skip write if no change
return nil
}
return write(path, formatted)
}

Expand Down

0 comments on commit f05ccdc

Please sign in to comment.