#!/bin/sh
# Pre-commit: same checks as CI. Fix here, not in CI.
set -e
echo "🔍 Pre-commit checks..."

# Lint + types (only if TS files staged)
STAGED_TS=$(git diff --cached --name-only | grep -E '\.(ts|tsx)$' || true)
if [ -n "$STAGED_TS" ]; then
  echo "  → lint + tsc..."
  pnpm lint --quiet
  npx tsc --noEmit
fi

# Unit tests
echo "  → tests..."
pnpm test --run --silent

echo "✅ Pre-commit passed"
