Skip to content

Instantly share code, notes, and snippets.

@doliG
Created April 17, 2018 14:57
Show Gist options
  • Select an option

  • Save doliG/73d39e493977a11e312006b8cb400338 to your computer and use it in GitHub Desktop.

Select an option

Save doliG/73d39e493977a11e312006b8cb400338 to your computer and use it in GitHub Desktop.
#!/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