-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
allow formating of multiple files #19442
Comments
This would make using tools like https://github.com/okonet/lint-staged much easier. |
Looks like we have a potential fix in #19528. Can this be looked at by a contributor? @teamterraform |
Just came across this and I am also using Create a script, I called it const execSync = require("child_process").execSync;
const paths = process.argv.slice(2); // the command to be run is "node terraform-multi-fmt.js <path1> <path2> ...", so slice(2) creates an array of ["path1", "path2", ...]
for (const path of paths) {
execSync(`terraform fmt ${path}`, { stdio: "inherit" });
} Then you can add it to "lint-staged": {
"**/*.tf": [
"node terraform-multi-fmt.js"
]
} |
For lint-staged users, there is an option to run a lint-staged command once per file using this configuration: https://github.com/okonet/lint-staged#example-wrap-filenames-in-single-quotes-and-run-once-per-file |
This appears to be resolved in v1.4.4. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. |
Current Terraform Version
Use-cases
format more than one file at a time, but not an directory. especially since
fmt
tries to format every file in the.terraform
directory as well.Attempted Solutions
in order to format more than one file, one has to use a loop or specifiy
terraform fmt
on each file separately since thefmt
command only supports format of an entire directory or a single file.Proposal
support
terraform fmt file [file ..]
so one can format more that one file at once, but not an entire directory.References
The text was updated successfully, but these errors were encountered: