Here's how this works:
- Include a
git_hooks/
directory in your project, with these two files (plus other hooks if you want, written in a similar style). - Add
"npm"
to yourdevDependencies
inpackage.json
, so that thepre-commit
hook can do its magic. - Add
test
andlint
scripts to yourpackage.json
, e.g.
"scripts": {
"test": "mocha",
"lint": "jshint ./lib --show-non-errors"
}
- Whenever you clone the repository, run
node git_hooks/link.js
to symlink the hooks stored in the repository, ingit_hooks
, to the hidden.git/hooks
directory.
Instead of running
node git_hooks/link.js
manually after each clone, how about making it a part ofnpm install
?