Skip to content

Instantly share code, notes, and snippets.

@stowball
Created October 14, 2016 06:50
Show Gist options
  • Save stowball/e2c7caef2d7767cc73ee908926722879 to your computer and use it in GitHub Desktop.
Save stowball/e2c7caef2d7767cc73ee908926722879 to your computer and use it in GitHub Desktop.
totvs pre-commit hook
#!/bin/sh
files=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$")
if [ "$files" = "" ]; then
exit 0
fi
eslint=$PWD/app/web-apps/node_modules/gulp-eslint/node_modules/eslint/bin/eslint.js
for file in ${files}; do
result=$($eslint -c app/web-apps/mdm-ui/.eslintrc ${file})
if [[ "$result" == *"problem"* ]]; then
$eslint -c app/web-apps/mdm-ui/.eslintrc ${files}
echo "\033[41mCOMMIT FAILED:\033[0m Your commit contains lint errors and/or warnings\n"
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment