mirror of
https://github.com/Sea-Haven-Industries/engineering-handbook.git
synced 2026-09-30 09:13:14 +00:00
20 lines
573 B
Text
20 lines
573 B
Text
|
|
#!/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."
|