Skip to content

Instantly share code, notes, and snippets.

@hmps
Last active February 1, 2018 08:06
Show Gist options
  • Save hmps/0b9d3d8fbca78640f1395101b981e624 to your computer and use it in GitHub Desktop.
Save hmps/0b9d3d8fbca78640f1395101b981e624 to your computer and use it in GitHub Desktop.
Post-merge githook to update dependencies for a React Native project
#!/bin/sh
# MIT © 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/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "Checking for changes in $1"
echo "$changed_files" | grep --quiet "$1" && echo "Running $2" && eval "$2"
}
check_run yarn.lock "yarn"
check_run Gemfile.lock "cd ios && bundle"
check_run Podfile.lock "cd ios && pod install"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment