Skip to content

Instantly share code, notes, and snippets.

@awave1
Created February 7, 2018 02:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awave1/d57f839c2f1d585b4e8c5d8135521074 to your computer and use it in GitHub Desktop.
Save awave1/d57f839c2f1d585b4e8c5d8135521074 to your computer and use it in GitHub Desktop.
pre-commit script
#!/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