fix(depotfmt): handle multiple terraform files
`terraform fmt` can only handle a single path, but treefmt expects formatters to be able to handle multiple paths at once. this wraps it in a small shell script that calls `terraform fmt` with at most one path at a time. Change-Id: I2b9c1b89b5a276f3d4915b95608ce36b2509e334 Reviewed-on: https://cl.tvl.fyi/c/depot/+/4639 Tested-by: BuildkiteCI Autosubmit: tazjin <mail@tazj.in> Reviewed-by: grfn <grfn@gws.fyi>
This commit is contained in:
parent
c1d7714a21
commit
8a5ccd7089
1 changed files with 7 additions and 2 deletions
|
@ -3,6 +3,12 @@
|
|||
{ depot, pkgs, ... }:
|
||||
|
||||
let
|
||||
# terraform fmt can't handle multiple paths at once, but treefmt
|
||||
# expects this
|
||||
terraformat = pkgs.writeShellScript "terraformat" ''
|
||||
echo "$@" | xargs -n1 ${pkgs.terraform}/bin/terraform fmt
|
||||
'';
|
||||
|
||||
config = pkgs.writeText "depot-treefmt-config" ''
|
||||
[formatter.go]
|
||||
command = "${pkgs.go}/bin/gofmt"
|
||||
|
@ -10,8 +16,7 @@ let
|
|||
includes = ["*.go"]
|
||||
|
||||
[formatter.tf]
|
||||
command = "${pkgs.terraform}/bin/terraform"
|
||||
options = [ "fmt" ]
|
||||
command = "${terraformat}"
|
||||
includes = [ "*.tf" ]
|
||||
'';
|
||||
|
||||
|
|
Loading…
Reference in a new issue