fix: print unchanged formatted file when using stdin (#11047)

Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
pull/11068/head
Yoan Blanc 5 years ago committed by GitHub
parent 4be9dfd183
commit 36a7b28b5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -156,6 +156,7 @@ func Test_fmt_pipe(t *testing.T) {
expected string
}{
{unformattedHCL, []string{"fmt", "-"}, nil, formattedHCL},
{formattedHCL, []string{"fmt", "-"}, nil, formattedHCL},
}
for _, tc := range tc {

@ -139,6 +139,10 @@ func (f *HCL2Formatter) processFile(filename string) ([]byte, error) {
outSrc := hclwrite.Format(inSrc)
if bytes.Equal(inSrc, outSrc) {
if filename == "-" {
_, _ = f.Output.Write(outSrc)
}
return nil, nil
}

Loading…
Cancel
Save