Created
August 5, 2017 19:38
-
-
Save femontanha/3683125ca2964719db4d47d4836f6138 to your computer and use it in GitHub Desktop.
pre-commit esw
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 | |
# ESLint Pre Commit Check | |
# put to `.git/hooks/pre-commit` | |
eslint_check() { | |
files=$(git diff --cached --name-only --diff-filter=AM | grep '\.jsx\?$') | |
if [[ $files = "" ]] ; then | |
return | |
fi | |
failed=0 | |
for file in ${files}; do | |
git show :$file | esw --color $file | |
if [[ $? != 0 ]] ; then | |
failed=1 | |
fi | |
done; | |
if [[ $failed != 0 ]] ; then | |
echo "🚫 ESLint failed, git commit denied!" | |
exit $failed | |
fi | |
} | |
eslint_check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment