Created
February 7, 2018 02:17
-
-
Save awave1/d57f839c2f1d585b4e8c5d8135521074 to your computer and use it in GitHub Desktop.
pre-commit script
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/bash | |
js_files=$(git diff --name-only | grep "\.js\?$") | |
eslint="" | |
check_failed=0 | |
for file in $js_files; do | |
if [[ $file == app* ]]; then | |
eslint="./app/node_modules/eslint/bin/eslint.js" | |
else | |
eslint="./node_modules/eslint/bin/eslint.js" | |
fi | |
git show :$file | "$eslint" "$file" | |
if [[ $? != 0 ]]; then | |
check_failed=1 | |
fi | |
done; | |
if [[ check_failed != 0 ]]; then | |
echo "whoa stop and fix lint errors pls" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment