Skip to content

Instantly share code, notes, and snippets.

@tigerclaw-az
Created January 22, 2014 16:59
Show Gist options
  • Save tigerclaw-az/8562518 to your computer and use it in GitHub Desktop.
Save tigerclaw-az/8562518 to your computer and use it in GitHub Desktop.
Git pre-commit hook that will run jshint against files being committed
#!/bin/sh
files=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$")
if [ "$files" = "" ]; then
exit 0
fi
pass=true
for file in ${files}; do
result=$(jshint ${file} | grep "${file}")
if [ "$result" != "" ]; then
echo "\033[31m$result\033[0m\n"
pass=false
fi
done
if ! $pass; then
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment