Skip to content

Commit

Permalink
tflint: upwrap directory passing
Browse files Browse the repository at this point in the history
  • Loading branch information
lexton committed Apr 27, 2023
1 parent e1d78ae commit 3e96e3c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hooks/terraform_tflint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ function per_dir_hook_unique_part {
shift
local -a -r args=("$@")

# we want to use the chdir function of tflint so that the errors are relative to the repo root
popd > /dev/null

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

tflint "${args[@]}"
tflint --chdir="$dir_path" "${args[@]}"
}

# return exit code to common::per_dir_hook
local exit_code=$?
pushd $dir_path > /dev/null
return $exit_code
}

Expand Down

0 comments on commit 3e96e3c

Please sign in to comment.