Skip to content

Instantly share code, notes, and snippets.

@mizobuchi
Created July 14, 2016 01:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mizobuchi/f19bffc785de9a2b540b7e13b0fe2779 to your computer and use it in GitHub Desktop.
Save mizobuchi/f19bffc785de9a2b540b7e13b0fe2779 to your computer and use it in GitHub Desktop.
#!/bin/sh
files=$(git diff --cached --name-only --diff-filter=ACM)
javascripts=$(echo "$files" | grep -e ".js$")
warn=false
pass=true
if [ "$javascripts" != "" ]; then
for javascript in ${javascripts}; do
result=$(./node_modules/.bin/eslint ${javascript} -f compact)
if [ "$(echo $result | grep Error)" = "" ]; then
if [ "$(echo $result | grep Warning)" = "" ]; then
echo "\t\033[32m✓ [eslint] ${javascript}\033[0m"
else
warn=true
echo "\t\033[33m⚠︎︎ [eslint] ${javascript}\033[0m"
fi
else
echo "\t\033[31m✗ [eslint] ${javascript}\033[0m"
pass=false
fi
done
fi
if ! $pass; then
echo "\n\033[31m✗ \033[0m\n"
exit 1
elif $warn; then
echo "\n\033[33m⚠︎ \033[0m\n"
exit 0
else
echo "\n\033[32m✓ \033[0m\n"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment