Created
May 19, 2021 12:11
-
-
Save mrtry/6a624966e536299e9ca9157ed89cad7d to your computer and use it in GitHub Desktop.
run `npm install` when update package.json
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/sh | |
. "$(dirname "$0")/_/husky.sh" | |
prevHEAD=$1 | |
nextHEAD=$2 | |
prevPackageHash=$(git log --format="%C(auto)%h%Creset" -n 1 $prevHEAD -- package.json | cat) | |
nextPackageHash=$(git log --format="%C(auto)%h%Creset" -n 1 $nextHEAD -- package.json | cat) | |
if [ "$prevPackageHash" != "$nextPackageHash" ]; then | |
npm i | |
else | |
echo "post-checkout: do nothing" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
git diff —exit-code —quiet
で差分あるかを調べれるが、帰ってきたexit-codeでhookが終了してしまうので、git logからのhashで比較してる