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.
Nifty! Should probably nest the "lint" command underneath the "test" command. This way, you don't exit in the middle of a test if lint fails, or vice-versa.