fix: print unchanged formatted file when using stdin (#11047)
Signed-off-by: Yoan Blanc <yoan@dosimple.ch>
This commit is contained in:
parent
4be9dfd183
commit
36a7b28b5f
|
@ -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…
Reference in New Issue