Skip to content

Commit

Permalink
#912: fix call to git diff
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed May 17, 2023
1 parent 13de337 commit 48a19da
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
11 changes: 2 additions & 9 deletions .husky/post-checkout
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,17 @@ echo "#$TICKETID: " > ".git/templatemessage"


# ### run npm install ###
echo "[POST-CHECKOUT-1]"
IFS=$'\n'
echo "[POST-CHECKOUT-2]"
# regex supports mono-repos with a package.json at root-level and at package-level
PACKAGE_LOCK_REGEX="(^packages\/.*\/package-lock\.json)|(^package-lock\.json)"
echo "[POST-CHECKOUT-3]"
# extract all paths to package-lock.json files
PACKAGES=("git diff --name-only HEAD@{1} HEAD | grep -E "$PACKAGE_LOCK_REGEX)
PACKAGES=`git diff --name-only HEAD^1 HEAD | grep -E '(^package-lock\.json)'`
echo "[POST-CHECKOUT-4]"

if [[ ${PACKAGES[@]} ]]; then
for package in $PACKAGES; do
echo "[POST-CHECKOUT]"
echo "📦 $package was changed. Running npm install to update your dependencies..."
# DIR=$(dirname package)
# cd "$DIR" && npm install
npm install
done
npm install
else
echo "📦 All packages up-to-date. No need to run npm install."
fi
10 changes: 2 additions & 8 deletions .husky/post-merge
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@
echo "[POST-MERGE-1]"

IFS=$'\n'
echo "[POST-MERGE-2]"
# regex supports mono-repos with a package.json at root-level and at package-level
PACKAGE_LOCK_REGEX="(^packages\/.*\/package-lock\.json)|(^package-lock\.json)"
echo "[POST-MERGE-3]"
# extract all paths to package-lock.json files
PACKAGES=("git diff --name-only HEAD@{1} HEAD | grep -E "$PACKAGE_LOCK_REGEX)
PACKAGES=`git diff --name-only HEAD^1 HEAD | grep -E '(^package-lock\.json)'`
echo "[POST-MERGE-4]"

if [[ ${PACKAGES[@]} ]]; then
for package in $PACKAGES; do
echo "[POST-MERGE]"
echo "📦 $package was changed. Running npm install to update your dependencies..."
# DIR=$(dirname package)
# cd "$DIR" && npm install
npm install
done
npm install
else
echo "📦 All packages up-to-date. No need to run npm install."
fi

0 comments on commit 48a19da

Please sign in to comment.