vercel / git-hooks

No nonsense Git hook management
MIT License
200 stars 10 forks source link

@vercel/git-hooks

No nonsense Git hook management.

Usage

Install this module, preferably as a dev-dependency:

yarn add --dev @vercel/git-hooks

That's it. You can now use the module in two ways:

{
  "scripts": {
    "git-pre-commit": "eslint"
  }
}

The above will run a single command line, just like running npm run git-pre-commit or yarn git-pre-commit, every time you git commit.

Alternatively, if you'd like to run several scripts in succession upon a hook, you may define a git top-level property and specify an array of scripts to run:

{
  "git": {
    "pre-commit": "lint"
  }
}

or

{
  "git": {
    "pre-commit": ["lint", "test"]
  }
}

Note that any "scripts" hooks supplant any corresponding "git" hooks. That is to say, if you define both a {"scripts": {"git-pre-commit": "..."}} hook and a {"git": {"pre-commit": []}} hook, the hook in "scripts" will be the only hook that is executed.

Why? There are hundreds of these.

*Caveat: The package manager needs to be npm compliant in terms of environment variables. Worst case, define the environment variables npm_node_execpath (node binary) and npm_execpath (package manager entry point) as environment variables prior to installing.

License

Copyright © 2021 by Vercel, Inc.

Released under the MIT License.