#!/usr/bin/env sh

echo "Running pre-commit: staged lint + format"

if ! command -v npm >/dev/null 2>&1; then
	echo "npm not found in PATH. Install Node.js/npm before committing." >&2
	exit 1
fi

if ! npx --no -- lint-staged; then
	echo "Pre-commit checks failed. Fix the lint errors and try again."
	echo "TIP: Run 'npm run lint' to apply autofixes, then review and recommit."
	exit 1
fi

echo "Pre-commit checks passed."
echo "TIP: Run 'npm run prtasks' to run CI checks locally."
