Skip to main content

max / balanced_breakfast

802 B · 22 lines History Blame Raw
1 #!/bin/bash
2 # Repo-local pre-commit extras, run last by the canonical hook.
3 #
4 # The JS suite. It is here rather than in the canonical hook because BB is the
5 # only repo that runs it separately: goingson's scripts/lint-frontend.sh runs its
6 # own suite internally, and BB's does not. If a second repo ever wants this, move
7 # it into the canonical hook behind a `[ -d <tests dir> ]` check rather than
8 # copying the file.
9 set -euo pipefail
10
11 ROOT="$(git rev-parse --show-toplevel)"
12 cd "$ROOT"
13
14 staged_js="$(git diff --cached --name-only --diff-filter=ACMR -- 'src-tauri/frontend/*')"
15 [ -n "$staged_js" ] || exit 0
16
17 echo "pre-commit: JS tests..."
18 if ! node --test 'src-tauri/frontend/js/tests/*.test.js'; then
19 echo "pre-commit: JS tests failed, commit aborted (use --no-verify to bypass)."
20 exit 1
21 fi
22