Skip to content

Commit f69e3fb

Browse files
authored
Add terraform fmt to the precommit hook (#110)
1 parent 5f0702d commit f69e3fb

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

.githooks/pre-commit

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ if command_exists typos; then
3333
echo "$files" | xargs typos
3434
fi
3535

36+
if command_exists terraform; then
37+
# `terraform fmt` doesn't ignore non-tf files automatically
38+
tf_files=$(echo "$files" | { grep -E '\.tf$' || true; })
39+
40+
echo "$tf_files" | xargs terraform fmt
41+
fi
42+
3643
if command_exists terraform-docs; then
3744
for tf_module in $tf_modules; do
3845
terraform-docs markdown "$tf_module" --output-file "README.md"

0 commit comments

Comments
 (0)