dash-website/_tests/git hooks/precommit
2017-06-07 11:24:34 +07:00

17 lines
393 B
Bash
Executable file

#!/bin/bash
jsfiles=$(git diff --cached --name-only --diff-filter=M | grep '\.js\?$')
jsfailed=0
if [[ $jsfiles != "" ]] ; then
for file in ${jsfiles}; do
git show :$file | eslint --stdin --stdin-filename "$file"
if [[ $? != 0 ]] ; then
jsfailed=1
fi
done;
fi
if [[ $jsfailed != 0 ]] ; then
echo "🚫🚫🚫ESLint must pass before committing .js files"
exit 1
fi