Skip to content

Fix terraform fmt hook where it is now running on all files regardless of exclude #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 7, 2020

Conversation

yorinasub17
Copy link
Contributor

This fixes a bug with our terraform fmt hook that was introduced in #15.

Specifically, terraform fmt -r ignores the exclude configuration. This makes it hard for our repos that are testing malformed terraform files as they will never pass the terraform fmt precommit hook.

Instead, we go through each file to run through terraform fmt.

@yorinasub17 yorinasub17 requested a review from brikis98 as a code owner February 6, 2020 22:21
terraform fmt -recursive
for file in "$@"; do
tmp_file="$(mktemp)"
terraform fmt - <"$file" >"$tmp_file"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-write=true I think will do what you need

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. My problem was that the docs was saying the args are DIR, not FILE but it turns out it works fine with files.

@yorinasub17
Copy link
Contributor Author

Thanks for review! Merging and releasing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants