Created
September 28, 2017 02:35
-
-
Save guilhermejcgois/0e92c04a4878ddd7edde586711e9564d to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
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