Created
January 14, 2018 05:43
-
-
Save yalab/b60891f9ed2029f7bc62197a5538882a to your computer and use it in GitHub Desktop.
ブランチを切り替えて Gemfile.lock や yarn.lock に変更があったら勝手に install する git hook
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/bash | |
PREV=$1 | |
POST=$2 | |
TRUE="1" | |
FALSE="0" | |
isChanged (){ | |
FILE_CHANGED="$(git log $PREV..$POST --pretty='format:' --name-only | grep $1)" | |
if [ -n "$FILE_CHANGED" ];then | |
echo $TRUE | |
else | |
echo $FALSE | |
fi | |
} | |
if [ $(isChanged 'Gemfile.lock') = $TRUE ];then | |
bundle install | |
fi | |
if [ $(isChanged "yarn.lock") = $TRUE ];then | |
yarn install | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment