Closed tomeon closed 4 months ago
Do you mind also contacting upstream so it eventually gets fixed?
Done: hashicorp/packer#12883.
Isn't this the same as hclfmt
though?
probably. I would use hclfmt
as it follows the treefmt spec. But I haven't used Packer for a while, maybe there is some extra semantic that packer fmt
understands?
[M]aybe there is some extra semantic that packer fmt understands?
Allegedly several of the <hashicorp-tool> fmt
subcommands, including packer fmt
, have tool-specific behavior, according to Hashicorp employees/contributors here and here. Such that running hclfmt
after packer fmt
is (or should be) idempotent, but running packer fmt
after hclfmt
isn't.
Due to the fact that
packer fmt
accepts only a single file or directory as an argument, this PR includes a not-particularly-pretty wrapper script that calls out topacker fmt
once per included source file, and a not-particularly-robust mechanism for distinguishing included source files frompacker fmt
options (basically, trying to plop a bare--
between options and source file arguments).Also includes some updates to the "Adding new formatters" section of the README; would be happy to spin these changes into a separate PR if that's preferable.
Thanks in advance!