Skip to content

Commit 3e96e3c

Browse files
committed
tflint: upwrap directory passing
1 parent e1d78ae commit 3e96e3c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

hooks/terraform_tflint.sh

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

53+
# we want to use the chdir function of tflint so that the errors are relative to the repo root
54+
popd > /dev/null
55+
5356
# Print checked PATH **only** if TFLint have any messages
5457
# shellcheck disable=SC2091,SC2068 # Suppress error output
55-
$(tflint ${args[@]} 2>&1) 2> /dev/null || {
58+
$(tflint --chdir="$dir_path" ${args[@]} 2>&1) 2> /dev/null || {
5659
common::colorify "yellow" "TFLint in $dir_path/:"
5760

58-
tflint "${args[@]}"
61+
tflint --chdir="$dir_path" "${args[@]}"
5962
}
6063

6164
# return exit code to common::per_dir_hook
6265
local exit_code=$?
66+
pushd $dir_path > /dev/null
6367
return $exit_code
6468
}
6569

0 commit comments

Comments
 (0)