Skip to content

Instantly share code, notes, and snippets.

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 azatoth/414991 to your computer and use it in GitHub Desktop.
Save azatoth/414991 to your computer and use it in GitHub Desktop.
if [ "$allowjsconsole" != "true" ]; then
jsfiles=$(git diff --cached --name-only --relative $against | sed -n '/\.js$/p');
if [ -n "$jsfiles" ] &&
[ -n "$( git diff --cached -Sconsole. $jsfiles | sed -n 's/console\.\(\w\+\)(.*\?)/&/p')" ];
then
echo "Error: Attempt to commit javascript with js console usage."
echo
echo "This might upset the master people..."
echo
echo "if you don't care about their wishes, you can disable"
echo "this check by using:"
echo
echo " git config hooks.allowjsconsole true"
echo
exit 1
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment