Skip to content

Commit 49974ab

Browse files
lextonMaxymVlasov
andauthored
fix: Speed up x2 TFLint hook execution in dirs with violations (antonbabenko#514)
Co-authored-by: Maksym Vlasov <[email protected]>
1 parent 0981505 commit 49974ab

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

hooks/terraform_tflint.sh

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,15 @@ function per_dir_hook_unique_part {
5050
shift
5151
local -a -r args=("$@")
5252

53-
# Print checked PATH **only** if TFLint have any messages
54-
# shellcheck disable=SC2091,SC2068 # Suppress error output
55-
$(tflint ${args[@]} 2>&1) 2> /dev/null || {
56-
common::colorify "yellow" "TFLint in $dir_path/:"
53+
TFLINT_OUTPUT=$(tflint "${args[@]}" 2>&1)
54+
local exit_code=$?
5755

58-
tflint "${args[@]}"
59-
}
56+
if [ $exit_code -ne 0 ]; then
57+
common::colorify "yellow" "TFLint in $dir_path/:"
58+
echo "$TFLINT_OUTPUT"
59+
fi
6060

6161
# return exit code to common::per_dir_hook
62-
local exit_code=$?
6362
return $exit_code
6463
}
6564

0 commit comments

Comments
 (0)