tridactyl/hooks/pre-commit
Colin Caine d28fc7f0f6 Add npm run {lint,pretty}
Lint is an alias to hooks/pre-commit. Code shared in scripts/common.
2018-05-18 16:03:11 +01:00

23 lines
509 B
Bash
Executable file

#!/bin/bash
source ./scripts/common
jsfiles=$(cachedJS)
[ -z "$jsfiles" ] && exit 0
# Check if any of the files are ugly or contain a console.log call
consoleFiles=$(noisy $jsfiles)
uglyFiles=$(ugly $jsfiles)
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 '$(npm bin)/prettier --write' "${uglyFiles[@]}"
exit 1
fi