Merge pull request #470 from alixander/fmt-save
only write fmt if changed
This commit is contained in:
commit
c912cae80a
2 changed files with 8 additions and 1 deletions
|
|
@ -3,3 +3,5 @@
|
|||
#### Improvements 🧹
|
||||
|
||||
#### Bugfixes ⛑️
|
||||
|
||||
- `d2 fmt` only rewrites if it has changes, instead of always rewriting. [#470](https://github.com/terrastruct/d2/pull/470)
|
||||
|
|
|
|||
7
fmt.go
7
fmt.go
|
|
@ -33,5 +33,10 @@ func fmtCmd(ctx context.Context, ms *xmain.State) (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
return ms.WritePath(inputPath, []byte(d2format.Format(m)))
|
||||
output := []byte(d2format.Format(m))
|
||||
if !bytes.Equal(output, input) {
|
||||
return ms.WritePath(inputPath, output)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue