Skip to content

Instantly share code, notes, and snippets.

@wjmazza
Forked from sindresorhus/post-merge
Created April 17, 2015 22:21
Show Gist options
  • Save wjmazza/38c007ee3350d685c0dc to your computer and use it in GitHub Desktop.
Save wjmazza/38c007ee3350d685c0dc to your computer and use it in GitHub Desktop.
#/usr/bin/env bash
# Originally based on https://gist.github.com/sindresorhus/7996717
# by Sindre Sorhus (sindresorhus.com)
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
if git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet -E "package.json";
then
echo ">>> package.json file has changed <<<"
echo "Deleting current node_modules folder (rm -rf ./node_modules)"
rm -rf ./node_modules
echo "Clearning npm cache (npm cache clean)"
npm cache clean
echo "Installing node modules (npm install)"
npm install
fi
if git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD | grep --quiet -E "bower.json";
then
echo ">>> bower.json file has changed <<<"
echo "Deleting current bower_components folder (rm -rf ./bower_components)"
rm -rf ./bower_components
echo "Clearning bower cache (bower cache clean)"
bower cache clean
echo "Pruning bower (bower prune)"
bower prune
echo "Installing bower components (bower install)"
bower install
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment