-
-
Save logicaroma/b1bb751c458d76246062 to your computer and use it in GitHub Desktop.
Precommit git hook
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 | |
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