#!/bin/sh

if [ -n "$CI" ]; then
  exit 0
fi

staged_files="$(git diff --cached --name-only --diff-filter=ACMR)"

if printf '%s\n' "$staged_files" | grep -q '^frontend/'; then
  if ! command -v pnpm >/dev/null 2>&1; then
    echo "pre-commit hook error: pnpm is required for frontend checks"
    exit 1
  fi

  pnpm --dir frontend lint
fi
