Skip to content

Instantly share code, notes, and snippets.

@wesm87
Last active November 10, 2017 17:45
Show Gist options
  • Save wesm87/4410958577f46dd2d5ec054e54dc6c72 to your computer and use it in GitHub Desktop.
Save wesm87/4410958577f46dd2d5ec054e54dc6c72 to your computer and use it in GitHub Desktop.
Git post-merge hook to auto-install dependencies
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
on_changed() {
echo "$changed_files" | grep --quiet "$1" && eval "$2" || return 0
}
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
source _helpers.sh
on_changed 'yarn.lock' 'yarn'
on_changed 'package-lock.json' 'npm install'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment