Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save danroberts/7900774 to your computer and use it in GitHub Desktop.
Save danroberts/7900774 to your computer and use it in GitHub Desktop.
#!/bin/sh
# 5:23 PM Friday, October 18, 2013 - Jim Priest
# origin script found here: http://python.dzone.com/articles/tips-using-git-pre-commit-hook
# Modified with console checks and to ignore commented file
FILES_PATTERN='\.(js|coffee)(\..+)?$'
FORBIDDEN='ddescribe\|iit\|console\.log'
if git diff --cached --name-only | grep -E -q $FILES_PATTERN ;
then
:
else
exit 0;
fi
if git diff --cached --name-only | \
grep -E $FILES_PATTERN | \
xargs grep --with-filename -n $FORBIDDEN;
then
echo 'COMMIT REJECTED! Found console. references. Please remove them before committing.'
exit 1;
fi
exit 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment