Last active
January 25, 2019 16:51
-
-
Save mrcnc/5ce8509f908e6935aa4302ca68c64c5b to your computer and use it in GitHub Desktop.
git pre-commit hook to format terraform files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env /bin/sh | |
set -e | |
files=$(git diff --cached --name-only --diff-filter=d) | |
for f in $files | |
do | |
if [ -e "$f" ] && [[ $f == *.tf ]]; then | |
printf "Formatting $f\n" | |
terraform fmt -check=true $f | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment