A simple, zero dependency tool for setting up git pre-commit hook for small projects
 
A tool, that let you set any command from package.json as a pre-commit hook.
- Zero dependency
- Easy to configure (one line in package.json)
- Lightweight
1. Install the simple-pre-commit as dev dependency
``sh`
npm install simple-pre-commit --save-dev
2. Add the simple-pre-commit to your package.json. Feed it with any command you would like to run as a pre-commit hook.`
json
"simple-pre-commit": "npx lint-staged"
``
> There are more ways to configure the package. Check out additional configuration
3. Run the CLI script to update the git hook with command from package.json
`sh`
npx simple-pre-commit
package.json
Now the command from is set up as executable git pre-commit hook.
Run npx simple-pre-commit from root of your project
Note that you should manually run npx simple-pre-commit every time you change the command
You can also add the .simple-pre-commit.json or simple-pre-commit.json to the project and write the command inside it, if you do not want to put command inside package.json
That way, .simple-pre-commit.json or simple-pre-commit.json should look like this and package.json may not have simple-pre-commit configuration inside it
`json`
{
"simple-pre-commit":"npx lint staged"
}
`sh``
npm uninstall --save-dev simple-pre-commit