Created
July 30, 2018 10:27
-
-
Save nguyenvanduocit/38829b8ed727605582bbca546b2fe184 to your computer and use it in GitHub Desktop.
Check for console.log before commit
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 | |
# 5:23 PM Friday, October 18, 2013 - Jim Priest | |
# origin script found here: http://python.dzone.com/articles/tips-using-git-pre-commit-hook | |
# Modified with console checks and to ignore commented file | |
echo "Executing post-commit checks..." | |
FILES_PATTERN='\.(js)(\..+)?$' | |
FORBIDDEN='console\.[clear|dir|log|info|warn|error]' | |
if git diff --cached --name-only | \ | |
grep -E $FILES_PATTERN | \ | |
xargs grep --with-filename -n $FORBIDDEN | \ | |
grep -v '//'; | |
then | |
echo 'COMMIT REJECTED! Found console. references. Please remove them before committing.' | |
exit 1; | |
fi | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment