pre-commit 710 Bytes
#!/usr/bin/env bash
# Pre-commit: ensure docs/prd/newfunction/_spec/ stays in sync with HTML source.
# Installed by scripts/install-hooks.sh (auto-run on `npm install` via "prepare" script).

set -e

changed=$(git diff --cached --name-only --diff-filter=ACMR | grep -E '^docs/prd/newfunction/.*\.html$' || true)

if [ -z "$changed" ]; then
  exit 0
fi

echo "[spec-sync] HTML source changed; checking docs/prd/newfunction/_spec/..."
if ! npm run -s spec:check; then
  echo ""
  echo "[spec-sync] _spec/ is stale. Fix with:"
  echo "    npm run spec:extract"
  echo "    git add docs/prd/newfunction/_spec/"
  echo ""
  echo "(or bypass once with:  git commit --no-verify  — only if intentional)"
  exit 1
fi