diff --git a/hooks/terraform-fmt.sh b/hooks/terraform-fmt.sh index 565f201c..77d023e9 100755 --- a/hooks/terraform-fmt.sh +++ b/hooks/terraform-fmt.sh @@ -12,7 +12,9 @@ export PATH=$PATH:/usr/local/bin FMT_ERROR=0 for file in "$@"; do - terraform fmt -diff -check "$file" || FMT_ERROR=$? + pushd "$(dirname "$file")" >/dev/null + terraform fmt -diff -check "$(basename "$file")" || FMT_ERROR=$? + popd >/dev/null done # reset path to the original value