From 49974ab9ef37e199d65778e6055aaf8130c6a875 Mon Sep 17 00:00:00 2001 From: Luke <9834514+lexton@users.noreply.github.com> Date: Fri, 28 Apr 2023 11:57:46 -0400 Subject: [PATCH] fix: Speed up x2 TFLint hook execution in dirs with violations (#514) Co-authored-by: Maksym Vlasov --- hooks/terraform_tflint.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index d488cb734..1a74ce344 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -50,16 +50,15 @@ function per_dir_hook_unique_part { shift local -a -r args=("$@") - # Print checked PATH **only** if TFLint have any messages - # shellcheck disable=SC2091,SC2068 # Suppress error output - $(tflint ${args[@]} 2>&1) 2> /dev/null || { - common::colorify "yellow" "TFLint in $dir_path/:" + TFLINT_OUTPUT=$(tflint "${args[@]}" 2>&1) + local exit_code=$? - tflint "${args[@]}" - } + if [ $exit_code -ne 0 ]; then + common::colorify "yellow" "TFLint in $dir_path/:" + echo "$TFLINT_OUTPUT" + fi # return exit code to common::per_dir_hook - local exit_code=$? return $exit_code }