Created
September 23, 2022 13:45
-
-
Save DanieleSalatti/13b2a516ee499bb701ee90a67ab8a553 to your computer and use it in GitHub Desktop.
pre-commit git hook to check for leftover console.log(s)
This file contains 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 | |
exec 1>&2 | |
exec < /dev/tty | |
consoleregexp='^\+.*console\.log(' | |
if test $(git diff --cached -U0 | grep $consoleregexp | wc -l) != 0 | |
then | |
exec git diff --cached | grep -ne $consoleregexp | |
read -p "It looks like you have left some console.log statements in your code. Are you sure want to continue? (y/n)" yn | |
echo $yn | grep ^[Yy]$ | |
if [ $? -eq 0 ] | |
then | |
exit 0; | |
else | |
exit 1; | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment