Description
I'm happy to implement this if it is acceptable.
I think it would be useful to be able to run subprocess specified by the configuration against files.
I thought of this idea because currently the pre-commit-terraform
hooks are implemented in Bash which is fine for Linux systems, or Windows if you're using WSL or Git Bash, but it fails from powershell or a regular command prompt.
I'm working with them to port hooks from bash to Python (since pre-commit is Python based anyway).
While I wait for this PR to maybe get accepted, I was thinking it would be nice if this pre-commit-hooks
repo had a hook where you could just specify a generic command.
Maybe it could behave similar to something like Bash's xargs. Maybe even give the hook the id of xargs
?
Example:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: vX.Y.Z
hooks:
# run terraform fmt against all .tf and .tfvars files
- id: xargs
args: ["terraform", "fmt"]
files: \.tf(vars)?$
exclude: \.terraform/.*$