Skip to content

proposal: generic subprocess #1037

@ericfrederich

Description

@ericfrederich

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/.*$

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions