Created
September 6, 2013 15:46
-
-
Save sindresorhus/6465739 to your computer and use it in GitHub Desktop.
Git hook to install npm dependencies after a `git pull`. Run `chmod +x post-merge` and put it in `.git/hooks/`. Though could really do whatever.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
npm install |
#!/usr/bin/env bash
set -e
prevHEAD=$1
newHEAD=$2
checkoutType=$3
[[ $checkoutType == 1 ]] && checkoutType='branch' ||
checkoutType='file' ;
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
[[ $checkoutType = 'branch' ]] && {
changed_files="$(git diff-tree -r --name-only --no-commit-id $prevHEAD $newHEAD)"
# node - use whichever works for you
check_run yarn.lock "yarn install"
# check_run package-lock.json "npm install"
# composer
check_run composer.lock "composer install"
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@pajtai see nvm-sh/nvm#688 (comment) (googled for "git hook nvm path")... don't be so lazy and do some research 🤓 your problem is not related to this script.