engineering-handbook/hooks/pre-push
Adam Moussa 2b5fe0f712 Add pre-push hook for npm ci validation
Catches lock file drift locally before it breaks CI. Includes
install instructions in git-workflow.md.
2026-05-14 18:25:10 -04:00

19 lines
573 B
Bash
Executable file

#!/usr/bin/env bash
# Pre-push hook: verify npm ci passes before pushing Node.js projects.
# Catches lock file drift that would break CI.
#
# Install: cp hooks/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push
set -euo pipefail
if [[ ! -f package-lock.json ]]; then
exit 0
fi
echo "pre-push: running npm ci..."
if ! npm ci --ignore-scripts --no-audit --no-fund 2>/dev/null; then
echo "pre-push: npm ci failed — lock file may be out of sync."
echo "Run: rm -rf node_modules package-lock.json && npm install"
exit 1
fi
echo "pre-push: npm ci passed."