Skip to content

Instantly share code, notes, and snippets.

@jakemhiller
Created May 26, 2016 19:25
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakemhiller/d342ad51505addf78ec628a16fd3280f to your computer and use it in GitHub Desktop.
Save jakemhiller/d342ad51505addf78ec628a16fd3280f to your computer and use it in GitHub Desktop.
git post-checkout hook for npm installing if package.json has changed between branches
#/usr/bin/env bash
changed_files="$(git diff-tree -r --name-only --no-commit-id $1 $2)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run npm-shrinkwrap.json "npm prune && npm install"
# check_run package.json "npm prune && npm install"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment