Files
dotfiles/.claude/hooks/async-bats.sh
Ismo Vuorinen cff83e4738 refactor(claude): migrate hooks to external scripts and add new hooks
Replace inline command strings in settings.json with external scripts
in .claude/hooks/ for readability and maintainability. Consolidate
three PostToolUse formatters into one script and add markdown/yaml
formatting. Add new hooks: SessionStart context banner, Stop lint
gate, async Bats test runner, idle desktop notification, and
PostToolUseFailure logger.
2026-03-20 04:38:18 +02:00

14 lines
422 B
Bash
Executable File

#!/usr/bin/env bash
# Async Bats runner: run matching test file when a script is edited.
# Runs in background (async: true) — output appears on next turn.
fp=$(jq -r '.tool_input.file_path // empty')
[ -z "$fp" ] && exit 0
name=$(basename "$fp")
test_file="$CLAUDE_PROJECT_DIR/tests/${name}.bats"
[ ! -f "$test_file" ] && exit 0
echo "Running $test_file ..."
"$CLAUDE_PROJECT_DIR/node_modules/.bin/bats" "$test_file"