Skip to content

Instantly share code, notes, and snippets.

@teppeis
Last active May 14, 2022 10:23
Show Gist options
  • Save teppeis/7367566 to your computer and use it in GitHub Desktop.
Save teppeis/7367566 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Check package.json and npm install after git checkout.
# Put this to .git/hooks/post-checkout
#
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"
npm install
fi
@plouc
Copy link

plouc commented Feb 18, 2016

running npm prune should be useful too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment