tridactyl/hooks/pre-commit
Rummskartoffel a366cddf11 Update git hooks
Add check to pre-commit hook to skip on Windows, where it is currently
partially broken
Notify user when hooks are run to replace similar shared-git-hooks
functionality
2020-11-26 22:26:37 +01:00

36 lines
864 B
Bash
Executable file

#!/usr/bin/env bash
case $(uname) in
*CYGWIN*|*MINGW*|*MSYS*)
echo "Cygwin/MinGW/MSYS detected, skipping pre-commit hook"
exit 0
;;
esac
echo "Running pre-commit hook..."
source ./scripts/common.sh
jsfiles=$(cachedTSLintFiles)
otherfiles=$(cachedPrettierFiles)
# Check if any of the files are ugly or contain a console.log call
consoleFiles=$(noisy $jsfiles)
uglyFiles="$(eslintUgly $jsfiles)"
if [ ! -n "$uglyFiles" ]; then
uglyFiles="$(prettierUgly $otherfiles)"
fi
if [ -n "$consoleFiles" ]; then
echo "Warning: adding console.log calls in ${consoleFiles[@]}"
echo 'Did you mean to use logger.debug?'
echo
fi
if [ -n "$uglyFiles" ]; then
echo "Prettify your files first:"
echo 'yarn run pretty'
echo ''
echo 'If you see this message repeatedly, skip the check with git commit -n'
exit 1
fi