Skip to content

Instantly share code, notes, and snippets.

@briansorahan
Last active August 29, 2015 14:03
Show Gist options
  • Save briansorahan/4a90818f724d9f4a0980 to your computer and use it in GitHub Desktop.
Save briansorahan/4a90818f724d9f4a0980 to your computer and use it in GitHub Desktop.
Running jshint and npm test in pre-commit git hook
#/bin/sh
#
# ...
#
# The pre-commit.sample template prefixes `git diff-index` with exec.
# This is a convenient way to make pre-commit exit with the status of this
# command, but we need to strip the exec prefix if we want to run other commands
# after git diff-index.
#
git diff-index --check --cached $against -- || exit 1
# Pass through the linter
jshint *.js || exit 1
# Run tests
npm test || exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment