Forked from martinwheeler/yarn-composer-post-merge-and-checkout-hooks.sh
Last active
July 25, 2018 01:38
-
-
Save realyze/f2a53a4119f955ff63337af72ebbc5cf to your computer and use it in GitHub Desktop.
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
#/usr/bin/env bash | |
git config --global init.templatedir '~/.git-templates' && \ | |
mkdir -p ~/.git-templates/hooks && \ | |
cd ~/.git-templates/hooks | |
cat >post-checkout <<'EOL' | |
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)" | |
check_run() { | |
echo "$changed_files" | grep -E --quiet "$1" && eval "$2" || true | |
} | |
# yarn all the things if yarn.lock has changed | |
check_run "web/yarn.lock" "cd web && yarn" | |
EOL | |
cp post-checkout ./post-merge && cp post-checkout ./post-fetch | |
chmod -R a+x . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will set up git hooks that ensure you
yarn
when you ought to.To install,
Important notes:
~/.git-templates
as this would overwrite them..git/hooks/
, this won't change them so you'll want to manually add the section inEOL