Skip to content

Commit

Permalink
Merge pull request #23 from gruntwork-io/yori-terragrunthclfmt
Browse files Browse the repository at this point in the history
Terragrunt hclfmt hook
  • Loading branch information
yorinasub17 authored Mar 29, 2020
2 parents 811a1fb + 86f6e6c commit 86acc66
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
files: \.tf$
exclude: \.+.terraform\/.*$

- id: terragrunt-hclfmt
name: Terragrunt hclfmt
description: Rewrites all Terragrunt configuration files to a canonical format
entry: hooks/terragrunt-hclfmt.sh
language: script
files: \.hcl$
exclude: >
(?x)^(
.+\.terraform\/.*$|
.+\.terragrunt-cache\/.*$|
)$
- id: shellcheck
name: Shellcheck Bash Linter
description: Performs linting on bash scripts
Expand Down
12 changes: 12 additions & 0 deletions hooks/terragrunt-hclfmt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

# OSX GUI apps do not pick up environment variables the same way as Terminal apps and there are no easy solutions,
# especially as Apple changes the GUI app behavior every release (see https://stackoverflow.com/q/135688/483528). As a
# workaround to allow GitHub Desktop to work, add this (hopefully harmless) setting here.
export PATH=$PATH:/usr/local/bin

for file in "$@"; do
terragrunt hclfmt --terragrunt-hclfmt-file "$file"
done

0 comments on commit 86acc66

Please sign in to comment.