Skip to content

Instantly share code, notes, and snippets.

@sirlancelot
Last active December 9, 2017 01:04
Show Gist options
  • Save sirlancelot/26cfc9702820a7d08a3a0e58ff611bc4 to your computer and use it in GitHub Desktop.
Save sirlancelot/26cfc9702820a7d08a3a0e58ff611bc4 to your computer and use it in GitHub Desktop.
Git hooks for Node.js
#!/bin/bash
# Warn when `package.json` is changed between checkouts.
PREVIOUS_HEAD=$1
NEW_HEAD=$2
BRANCH_SWITCH=$3
if [ $(git diff $PREVIOUS_HEAD..$NEW_HEAD --name-only -- package.json | wc -l) == "1" ]; then
echo "[post-checkout] \`package.json\` changed, running \`npm install --no-optional\`..."
npm install --no-optional
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment