Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Speed up x2 TFLint hook execution in dirs with violations #514

Merged
merged 3 commits into from
Apr 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 6 additions & 7 deletions hooks/terraform_tflint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down