Skip to content

Instantly share code, notes, and snippets.

@noahgrant
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noahgrant/57ee6ae5ffe9639069e4 to your computer and use it in GitHub Desktop.
Save noahgrant/57ee6ae5ffe9639069e4 to your computer and use it in GitHub Desktop.
a quick script to call bower install and npm install automatically if bower.json or package.json are changed, respectively. this file should be called post-merge and should be placed in /.git/hooks/. it should be executable. **this hook does not get triggered if your git pulls are set to auto rebase.
#!/bin/sh
# noah grant
# quick script to call bower install and npm install automatically if
# bower.json or package.json are changed, respectively.
# add to .git/hooks/
# this assumes one top-level file for each
changedfiles=( `git diff --name-only HEAD@{1}` )
if [[ "${changedfiles[*]}" =~ "bower.json" ]]; then
echo "bower installing"
bower install
fi
if [[ "${changedfiles[*]}" =~ "package.json" ]]; then
echo "npm installing"
npm install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment