Last active
October 4, 2018 08:13
-
-
Save valerykalashnikov/6522704 to your computer and use it in GitHub Desktop.
Precommit hook to prevent console.log, debugger and binding.pry
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/bash | |
#Precommit hook to prevent "debugger" and "console.log" | |
#Note: to enamble precommit on Windows machine don't forget add path to Git\bin and Git\cmd to PATH environment variable | |
count=0 | |
for FILE in `git diff-index --name-status HEAD -- | cut -c3-` ; do | |
# Check if the file contains 'debugger' or 'console.log' | |
contains=`grep -e "debugger" -e "console\.log" -e "binding\.pry" $FILE` | |
if [ `grep -e "debugger" -e "console\.log" -e "binding\.pry" $FILE|wc -l` -ne 0 ] | |
then | |
echo -e $FILE " contains " $contains | |
count=$[$count+1] | |
fi | |
done | |
if [ $count -eq 0 ] | |
then exit | |
else exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment