Merge pull request #98 from mcataford/build/pre-commit-check

build(git): add pre-commit to selective format, typecheck
This commit is contained in:
Marc 2023-12-31 14:27:27 -05:00 committed by GitHub
commit d91d587eae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View file

@ -15,4 +15,8 @@ if [[ -z $BIN_MATCH ]]; then
export PATH=$PATH:$BIN_PATH
fi
echo "Adding pre-commit hook"
cp ./script/pre-commit ./.git/hooks
chmod +x ./.git/hooks/pre-commit
echo "All done!"

16
script/pre-commit Executable file
View file

@ -0,0 +1,16 @@
#!/bin/sh
TASKS=""
if [ -n "$(git diff --cached --name-only origin/main -- ./frontend)" ]; then
TASKS="$TASKS fe:lint fe:typecheck"
fi
if [ -n "$(git diff --cached --name-only origin/main -- ./backend)" ]; then
TASKS="$TASKS be:lint"
fi
if [ -n "$TASKS" ]; then
echo "Running $TASKS"
task $TASKS
fi