From 640d2f7058aad6b217d93afaf57bd56ed23e7a82 Mon Sep 17 00:00:00 2001 From: Anton Ovchinnikov Date: Tue, 9 May 2023 13:16:01 +0200 Subject: [PATCH] Switch to file directory for terraform-fmt --- hooks/terraform-fmt.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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