Created
February 14, 2012 21:49
-
-
Save davglass/1830797 to your computer and use it in GitHub Desktop.
Greps for console.log|info|warn|error in source files.
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/bash | |
# Save this file somewhere in your path as git-console | |
# Then cd into a directory and execute git `console` | |
# This works well for yui3/src/module directories since it only checks ./js/* | |
#Scans the ./js/* dir or * for console.log, console.info, console.warn or console.error | |
# It will still pass if it finds //console.log, but it will not | |
# catch console.log statements inside a block comment: /* console.log */ | |
if [ -d "./js" ]; then | |
grep -R -e"console\.[log|info|warn|error]" ./js/* | grep -v '//' | |
else | |
grep -R -e"console\.[log|info|warn|error]" * | grep -v '//' | |
fi | |
retval=$? | |
if [ $retval == 0 ]; then | |
# grep returns a 0 when it returns a string, exit 1 to stop | |
exit 1; | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment