This repo has some handy handy hooks to run bower update
or npm install
whenever you:
git checkout
a new branch with a different package.json or bower.jsongit pull
a change to package.json or bower.json
#! /bin/bash | |
# post-checkout hook - looks for changes to bower.json or package.json, | |
# when you change branches, and if found, reinstalls the given packages every time you `git merge` or `git pull` | |
# | |
# To install: | |
# copy to your project's .git/hooks folder | |
# chmod +x .git/hooks/post-checkout | |
# | |
# Exit early if this was only a file checkout, not a branch change ($3 == 1) | |
[[ $3 == 0 ]] && exit 0 | |
oldRef=$1 | |
newRef=$2 | |
function changed { | |
git diff --name-only $oldRef $newRef | grep "^$1" > /dev/null 2>&1 | |
} | |
if changed 'bower.json'; then | |
echo "bower.json changed, installing" | |
bower update | |
fi | |
if changed 'package.json'; then | |
echo "Package.json changed, installing" | |
npm install | |
fi |
#!/bin/sh | |
# post-checkout hook - looks for changes to bower.json or package.json, and if | |
# found, reinstalls the given packages every time you `git merge` or `git pull` | |
# | |
# To install: | |
# copy to your project's .git/hooks folder | |
# chmod +x .git/hooks/post-merge | |
# | |
function changed { | |
git diff --name-only HEAD@{2} HEAD | grep "^$1" > /dev/null 2>&1 | |
} | |
if changed 'bower.json'; then | |
echo "bower.json changed, installing" | |
bower update | |
fi | |
if changed 'package.json'; then | |
echo "Package.json changed, installing" | |
npm install | |
fi |