Skip to content

Instantly share code, notes, and snippets.

@cathyxz
Created January 26, 2017 04:44
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 cathyxz/ec682da1dbd285474013099becd49bab to your computer and use it in GitHub Desktop.
Save cathyxz/ec682da1dbd285474013099becd49bab to your computer and use it in GitHub Desktop.
Pre-commit hook to reject commit if you have added console.logs
#!/bin/sh
count=`git diff HEAD | grep '+.*console\.log' | wc -l | awk '{print $1}'`
if [[ "$count" -ge 1 ]]; then
echo "Please remove console.log() statements from your changes before committing."
echo "Refusing to commit changes."
git diff HEAD | grep '+.*console\.log'
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment