diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 424e545..f788ca2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,5 +1,5 @@ - repo: git://github.com/pre-commit/pre-commit-hooks - sha: v0.4.2 + sha: v0.6.0 hooks: - id: check-yaml - id: end-of-file-fixer diff --git a/README.md b/README.md index e60d053..9811bd4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# pre-commit-terraform hooks +# pre-commit-terraform hook Single [pre-commit](http://pre-commit.com/) hook which runs `terraform fmt` on `*.tf` files. @@ -11,4 +11,4 @@ An example `.pre-commit-config.yaml`: - id: terraform_fmt ``` -Enjoy the clean code! \ No newline at end of file +Enjoy the clean code! diff --git a/hooks.yaml b/hooks.yaml index 0eebbde..27868a4 100644 --- a/hooks.yaml +++ b/hooks.yaml @@ -1,6 +1,7 @@ - id: terraform_fmt name: Terraform fmt description: Rewrites all Terraform configuration files to a canonical format. - entry: tffmthook.sh + entry: terrraform_fmt.sh language: script files: \.tf$ + exclude: \.terraform\/.*$ diff --git a/terrraform_fmt.sh b/terrraform_fmt.sh new file mode 100755 index 0000000..e1385a6 --- /dev/null +++ b/terrraform_fmt.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +for file in "$@"; do + terraform fmt `dirname $file` +done diff --git a/tffmthook.sh b/tffmthook.sh deleted file mode 100755 index 98f2192..0000000 --- a/tffmthook.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash - -[[ -z $(terraform fmt "$@") ]]