Skip to content

Instantly share code, notes, and snippets.

@troy0820
Created March 12, 2018 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save troy0820/8cfe7a38ba2533d987f4be8d708202a0 to your computer and use it in GitHub Desktop.
Save troy0820/8cfe7a38ba2533d987f4be8d708202a0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -e
files=$(git diff --cached --name-only)
for f in $files
do
if [ -e "$f" ] && [[ $f == *.tf ]]; then
#terraform validate `dirname $f`
terraform fmt $f
echo -e "\033[032m terraform formatted file: $f \033[0m"
git add $f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment