Skip to content

Instantly share code, notes, and snippets.

@jayu
Last active December 16, 2021 08:42
Show Gist options
  • Save jayu/4349fa040bff68c750816dd8e24156cd to your computer and use it in GitHub Desktop.
Save jayu/4349fa040bff68c750816dd8e24156cd to your computer and use it in GitHub Desktop.
Git hook to detect console.log and todo added to codebase before commit
CONSOLE_LOGS="$(git diff HEAD | grep -e '^\+.*console.log' -ie '^\+.*todo')"
if [ ${#CONSOLE_LOGS} -ge 1 ] ; then
printf "😮 console.logs or todos found in commit diff!\n\n"
printf "$CONSOLE_LOGS\n\n"
echo '🛑 terminating'
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment