Skip to content

Instantly share code, notes, and snippets.

@guilhermejcgois
Created September 28, 2017 02:35
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 guilhermejcgois/0e92c04a4878ddd7edde586711e9564d to your computer and use it in GitHub Desktop.
Save guilhermejcgois/0e92c04a4878ddd7edde586711e9564d to your computer and use it in GitHub Desktop.
#!/bin/sh
echo "\nChecking for console.logs()...\n"
# Get from http://frontend.turing.io/lessons/module-4/git-hooks.html
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='^\+.*console\.log('
debuggerregexp='debugger'
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
exec git diff --cached | grep -ne $consoleregexp
read -p "You have added one or more console logs in your modification. Are you sure want to continue? (y/n)" yn
echo $yn | grep ^[Yy]$
if [ $? -eq 0 ]
then
exit 0; # Let the user continue
else
exit 1; # Don't let the user continue
fi
fi
if test $(git diff --cached | grep $debuggerregexp | wc -l) != 0
then
exec git diff --cached | grep -ne $debuggerregexp
read -p "You have added one or more debuggers in your modification. Are you sure want to continue? (y/n)" yn
echo $yn | grep ^[Yy]$
if [ $? -eq 0 ]
then
exit 0; # Let the user continue
else
exit 1; # Don't let the user continue
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment