Created
January 22, 2014 16:59
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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