terraform fmt workaround

See #97
This commit is contained in:
zimbatm 2021-05-06 22:44:28 +02:00
parent dc25c5a742
commit f640dd9c9d
No known key found for this signature in database
GPG Key ID: 71BAF6D40C1D63D7
7 changed files with 30 additions and 1 deletions

View File

@ -37,6 +37,7 @@ quite tricky.
## Usage
`$ cargo run -- --help`
```
treefmt 0.1.1
✨ format all your language!

View File

@ -16,12 +16,17 @@ packages = [
# Code formatters
"elmPackages.elm-format",
"go",
"haskellPackages.ormolu",
"haskellPackages.cabal-fmt",
"haskellPackages.ormolu",
"nixpkgs-fmt",
"nodePackages.prettier",
"python3.pkgs.black",
"shfmt",
"terraform",
"mdbook"
]
[[env]]
name = "PATH"
eval = "$PWD/target/debug:$PATH"

View File

@ -125,3 +125,8 @@ options = [
]
includes = ["*.sh"]
```
## terraform
terraform fmt only supports formatting one file at the time. See
https://github.com/hashicorp/terraform/pull/28191

View File

@ -0,0 +1,4 @@
resource "my_resource" "xxx" {
option = [1, 2, 3]
}

View File

@ -0,0 +1,4 @@
resource "other_resource" "xxx" {
xxx = "xxx"
}

6
scripts/terraform-fmt Executable file
View File

@ -0,0 +1,6 @@
#!/usr/bin/env bash
set -euo pipefail
for path in "$@"; do
terraform fmt "$path"
done

View File

@ -63,3 +63,7 @@ options = [
"-w", # write back to the file
]
includes = ["*.sh"]
[formatter.terraform]
command = "./scripts/terraform-fmt"
includes = ["*.tf"]