Skip to content

Instantly share code, notes, and snippets.

@sgnh
Last active February 27, 2017 16:21
Show Gist options
  • Save sgnh/2d1d3fd56b5d4cf672a897d9533b1946 to your computer and use it in GitHub Desktop.
Save sgnh/2d1d3fd56b5d4cf672a897d9533b1946 to your computer and use it in GitHub Desktop.
Git post-checkout hook for reinstalling yarn packages
#!/bin/bash
PREVIOUS_HEAD=$1
NEW_HEAD=$2
BRANCH_SWITCH=$3
changed_files="$(git diff-tree -r --name-only --no-commit-id $PREVIOUS_HEAD $NEW_HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
}
check_run yarn.lock "yarn"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment