#!/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."