From 6576e4a74cd301f083b273e6f73eb0058f25362e Mon Sep 17 00:00:00 2001 From: Danny Coates Date: Thu, 5 Sep 2019 08:14:14 -0700 Subject: [PATCH] added sync-npm-dependencies script and hooks --- package.json | 3 ++- scripts/sync-npm-dependencies.sh | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100755 scripts/sync-npm-dependencies.sh diff --git a/package.json b/package.json index eae78085..5d1916d0 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,8 @@ "hooks": { "pre-commit": "lint-staged", "pre-push": "npm test", - "post-merge": "npm install" + "post-merge": "scripts/sync-npm-dependencies.sh", + "post-checkout": "scripts/sync-npm-dependencies.sh" } }, "lint-staged": { diff --git a/scripts/sync-npm-dependencies.sh b/scripts/sync-npm-dependencies.sh new file mode 100755 index 00000000..02349c35 --- /dev/null +++ b/scripts/sync-npm-dependencies.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "checking package-lock.json for changes" +if [ "$1" != "$2" ]; then + DIFF=$(git diff $1 $2 package-lock.json) + if [ "$DIFF" != "" ]; then + npm install + fi +fi \ No newline at end of file