Skip to content

Instantly share code, notes, and snippets.

@ConradIrwin
Created June 17, 2011 19:02
Show Gist options
  • Save ConradIrwin/1032053 to your computer and use it in GitHub Desktop.
Save ConradIrwin/1032053 to your computer and use it in GitHub Desktop.
jslint & whitespace on pre-commit
#!/bin/sh -e
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Check whitespace
git diff-index --check --cached $against --
# JSLINT (https://github.com/ConradIrwin/jslint-node)
jslint --ignore-no-files `git diff-index --name-only $against -- | grep '\.js$'`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment