#!/bin/sh
set -e

# Lint staged CSS files
STAGED_CSS=$(git diff --cached --name-only --diff-filter=ACM | grep '\.css$' || true)
if [ -n "$STAGED_CSS" ]; then
  echo "$STAGED_CSS" | tr '\n' '\0' | xargs -0 npx stylelint
fi

# Rebuild any generated artifacts whose sources changed and re-stage the outputs.
# Registration lives in scripts/artifacts.json — add entries there, not here.
node scripts/check-artifacts.js --fix
