Skip to content

Instantly share code, notes, and snippets.

@alonisser
Created December 29, 2013 08:43
Show Gist options
  • Save alonisser/8168644 to your computer and use it in GitHub Desktop.
Save alonisser/8168644 to your computer and use it in GitHub Desktop.
git hook for bower install and npm install on bower.json/package.json change
#!/bin/sh
#Inspired by https://gist.github.com/jbergantine/3870080
#Since every `git pull` is actually a merge. We can use it to automaticly run basic Django tasks after pulling from the upstream master branch (or any other)
#Notice: This won't run at git fetch. since fetch doesn't merge anything
#Installation:
# copy this script with the name:`post-merge.sh` to your project root folder
# symlink it to the ./git/hooks/post-merge: `ln post-merge.sh .git/hooks/post-merge
#You should have bash (windows users, means cygwin/mingw anything that works for you
#Based on the instructions here: https://oknesset-devel.readthedocs.org/en/latest/workflow.html#before-coding
if [ $(git diff HEAD@{1} HEAD --name-only | grep 'bower.json' -c) -ne 0 ]
then
bower install
fi
if [ $(git diff HEAD@{1} HEAD --name-only | grep 'package.json' -c) -ne 0 ]
then
npm install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment