Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions hooks/terraform-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ set -e
# workaround to allow GitHub Desktop to work, add this (hopefully harmless) setting here.
export PATH=$PATH:/usr/local/bin

# Store and return last failure from fmt so this can validate every directory passed before exiting
FMT_ERROR=0

for file in "$@"; do
pushd "$(dirname "$file")" >/dev/null
terraform fmt -write=true "$(basename "$file")"
popd >/dev/null
terraform fmt -diff -check "$file" || FMT_ERROR=$?
done

exit ${FMT_ERROR}