From 9ad9c9feb2892b1879baa8dcf12ad5eee3c114a1 Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Thu, 5 Sep 2019 13:16:32 -0700 Subject: [PATCH] fixed git hooks --- package.json | 2 +- scripts/sync-npm-dependencies.sh | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 5d1916d0..26ed04a3 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "hooks": { "pre-commit": "lint-staged", "pre-push": "npm test", - "post-merge": "scripts/sync-npm-dependencies.sh", + "post-merge": "npm install", "post-checkout": "scripts/sync-npm-dependencies.sh" } }, diff --git a/scripts/sync-npm-dependencies.sh b/scripts/sync-npm-dependencies.sh index 02349c35..6e5e100f 100755 --- a/scripts/sync-npm-dependencies.sh +++ b/scripts/sync-npm-dependencies.sh @@ -1,8 +1,12 @@ #!/bin/bash echo "checking package-lock.json for changes" -if [ "$1" != "$2" ]; then - DIFF=$(git diff $1 $2 package-lock.json) +IFS=' ' +read -ra G_PARAMS <<< "$HUSKY_GIT_PARAMS" +PREV=${G_PARAMS[0]} +NEXT=${G_PARAMS[1]} +if [ "$PREV" != "$NEXT" ]; then + DIFF=$(git diff $PREV $NEXT package-lock.json) if [ "$DIFF" != "" ]; then npm install fi