Created
June 30, 2015 06:36
-
-
Save pgilad/2b368d8a3bd815ba9968 to your computer and use it in GitHub Desktop.
Precommit git hook
This file contains hidden or 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 | |
JS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E "(.js|.es6)$") | |
if [ "$JS_FILES" = "" ]; then | |
exit 0 | |
fi | |
pass=true | |
for file in $JS_FILES; do | |
./node_modules/.bin/jscs --config .jscsrc "$file" | |
if [ $? -ne 0 ]; then | |
pass=false | |
fi | |
./node_modules/.bin/jshint --config .jshintrc "$file" | |
if [ $? -ne 0 ]; then | |
pass=false | |
fi | |
done | |
if [ "$pass" = true ]; then | |
exit 0 | |
else | |
echo "\033[41mCOMMIT FAILED:\033[0m Aborting commit due to errors" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment