Created
April 17, 2018 14:57
-
-
Save doliG/73d39e493977a11e312006b8cb400338 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 | |
| # Colors | |
| CGREEN="\033[32m" | |
| CRED="\033[31m" | |
| CNONE="\033[39m" | |
| CYELLOW="\033[33m" | |
| # Catch forbidden pattern in js files | |
| PATTERNS="console.log" | |
| FILES_WITH_DIFF=`git diff --cached --name-only -G $PATTERNS` | |
| if [ -n "$FILES_WITH_DIFF" ]; then | |
| echo "$CYELLOW[Hook]$CRED[ERROR]$CNONE There are some forbidden pattern in the diff. Please see the details below :" | |
| grep --color=auto -n "console.log" $FILES_WITH_DIFF | |
| exit 1 | |
| else | |
| echo "$CYELLOW[Hook]$CGREEN[OK]$CNONE No forbidden pattern" | |
| exit 0 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment