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 a symlink, since got very 2.9 you set hooksPath in local config. 'git config core.hooksPath ./git_hooks'