Skip to content

Commit 826ea88

Browse files
committed
fix(checks): improve error handling for terraform fmt command
1 parent 4cab98d commit 826ea88

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

checks/code_quality_tf.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,12 @@ func CodeQualityTf(modules map[string]data.TerraformModule) (data.Check, error)
3535

3636
runErr := cmd.Run()
3737
if runErr != nil {
38-
exitErr, ok := runErr.(*exec.ExitError)
39-
if !ok || exitErr.ExitCode() != 1 {
38+
_, ok := runErr.(*exec.ExitError)
39+
if !ok {
4040
return data.Check{}, fmt.Errorf("terraform fmt failed on %s: %w\n%s", module.FullPath, runErr, stderr.String())
4141
}
42+
// Any non-zero exit code from terraform fmt --check means files need formatting;
43+
// stdout contains the list of affected files.
4244
}
4345

4446
for _, file := range strings.Split(strings.TrimSpace(stdout.String()), "\n") {

0 commit comments

Comments
 (0)