Created
September 30, 2013 21:26
-
-
Save scurker/6770516 to your computer and use it in GitHub Desktop.
Stop console statements from going to git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Stop console.log statements from going into github | |
for file in `git diff-index --name-only HEAD --cached | egrep \.js$`; do | |
OUT=$(awk '/console\.(log|debug|warn|info)/ { print "\\t"NR": "; print $0; print "\\n" }' $file) | |
if [ -n "$OUT" ]; then | |
echo -e "\n".$file | |
echo -e $OUT | |
IS_ERROR=false | |
fi | |
done | |
if [ $IS_ERROR ]; then | |
echo -e "\nYou idiot! You left a console statement in your javascripts. Nice job!" | |
exit 1 | |
else | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment