From 3e96e3c1cacf1ce6363f7f6b06b3fb1b776477b6 Mon Sep 17 00:00:00 2001 From: Luke Exton Date: Wed, 26 Apr 2023 01:30:10 -0400 Subject: [PATCH] tflint: upwrap directory passing --- hooks/terraform_tflint.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hooks/terraform_tflint.sh b/hooks/terraform_tflint.sh index d488cb734..1f1414459 100755 --- a/hooks/terraform_tflint.sh +++ b/hooks/terraform_tflint.sh @@ -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 }