Skip to content

Instantly share code, notes, and snippets.

@scurker
Created September 30, 2013 21:26
Show Gist options
  • Save scurker/6770516 to your computer and use it in GitHub Desktop.
Save scurker/6770516 to your computer and use it in GitHub Desktop.
Stop console statements from going to git
#!/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