canvas-lms/hooks/pre-commit

23 lines
632 B
Bash
Executable File

#!/usr/bin/env bash
if [[ "$SKIP_CANVAS_PRECOMMIT_HOOK" == "1" ]]; then
exit 0
fi
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
CANVAS=$(dirname $SCRIPTPATH)
if [ `pwd -P` = $CANVAS ]; then
if [ -f node_modules/.bin/lint-staged ]; then
yarn run --silent lint:staged
else
echo 'Trying to run lint:staged inside Docker, if you want things quicker yarn install locally.'
docker-compose run --rm --no-deps web yarn run lint:staged ||
echo 'You should run `yarn` locally or check to make sure docker is running.'
fi
fi
$CANVAS/script/rlint ${RLINT_ARGUMENTS:- --auto-correct-all}
exit 0