2018-08-24 13:38:05 -06:00
|
|
|
#!/usr/bin/env bash
|
2018-03-06 22:03:44 +01:00
|
|
|
|
2020-11-26 22:22:08 +01:00
|
|
|
case $(uname) in
|
|
|
|
*CYGWIN*|*MINGW*|*MSYS*)
|
|
|
|
echo "Cygwin/MinGW/MSYS detected, skipping pre-commit hook"
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
echo "Running pre-commit hook..."
|
|
|
|
|
2019-05-29 17:48:32 +01:00
|
|
|
source ./scripts/common.sh
|
2018-05-18 15:35:32 +01:00
|
|
|
|
2019-04-06 22:50:01 +02:00
|
|
|
jsfiles=$(cachedTSLintFiles)
|
|
|
|
otherfiles=$(cachedPrettierFiles)
|
2018-04-14 16:59:02 +01:00
|
|
|
|
2018-05-18 07:21:13 +02:00
|
|
|
# Check if any of the files are ugly or contain a console.log call
|
2018-05-18 15:35:32 +01:00
|
|
|
consoleFiles=$(noisy $jsfiles)
|
2020-06-17 18:00:24 +01:00
|
|
|
uglyFiles="$(eslintUgly $jsfiles)"
|
2019-04-06 22:50:01 +02:00
|
|
|
if [ ! -n "$uglyFiles" ]; then
|
|
|
|
uglyFiles="$(prettierUgly $otherfiles)"
|
|
|
|
fi
|
2018-05-18 15:35:32 +01:00
|
|
|
|
|
|
|
if [ -n "$consoleFiles" ]; then
|
|
|
|
echo "Warning: adding console.log calls in ${consoleFiles[@]}"
|
|
|
|
echo 'Did you mean to use logger.debug?'
|
|
|
|
echo
|
|
|
|
fi
|
2018-04-14 16:59:02 +01:00
|
|
|
|
2018-05-18 07:21:13 +02:00
|
|
|
if [ -n "$uglyFiles" ]; then
|
2018-05-18 00:16:36 +01:00
|
|
|
echo "Prettify your files first:"
|
2019-05-31 16:48:53 +01:00
|
|
|
echo 'yarn run pretty'
|
2020-01-02 15:11:38 +00:00
|
|
|
echo ''
|
|
|
|
echo 'If you see this message repeatedly, skip the check with git commit -n'
|
2018-05-18 00:16:36 +01:00
|
|
|
exit 1
|
|
|
|
fi
|