Skip to content

Commit

Permalink
Merge pull request #913 from Accenture/task/912-ensure-mcdev-collabor…
Browse files Browse the repository at this point in the history
…ators-auto-update-their-dependencies-on-git-pull

Task/912 ensure mcdev collaborators auto update their dependencies on git pull
  • Loading branch information
JoernBerkefeld authored May 17, 2023
2 parents 3615299 + 3c84ef0 commit 45d29e8
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
28 changes: 27 additions & 1 deletion .husky/post-checkout
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

# ### git commit message template ###
git config commit.template .git/templatemessage
TICKETID=`git rev-parse --abbrev-ref HEAD | LC_ALL=en_US.utf8 grep -oP '((feature|bug|bugfix|fix|hotfix|task|chore)\/)\K\d{1,7}'`
echo "[POST_CHECKOUT] Setting template commit to $TICKETID"
echo "#$TICKETID: " > ".git/templatemessage"
echo "#$TICKETID: " > ".git/templatemessage"


# ### run npm install ###
echo "[POST-CHECKOUT] 📦 Checking for changes to dependencies"
# define how to split strings into array elements
IFS=$'\n'
# $1 is the new HEAD pointer
NEWHEAD=$1
# $2 is the previous HEAD pointer
OLDHEAD=$2
# extract all paths to package-lock.json files
PACKAGE_LOCK_REGEX="(^package-lock\.json)"
PACKAGES=$(git diff --name-only $NEWHEAD $OLDHEAD | grep -E $PACKAGE_LOCK_REGEX || true)

if [[ ${PACKAGES[@]} ]]; then
for package in $PACKAGES; do
echo "📦 $package was changed."
done
echo "📦 Running npm install to update your dependencies..."
npm install
else
echo "📦 All packages up-to-date. No need to run npm install."
fi
21 changes: 21 additions & 0 deletions .husky/post-merge
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/sh
# ### run npm install ###
. "$(dirname "$0")/_/husky.sh"


echo "[POST-MERGE] 📦 Checking for changes to dependencies"

IFS=$'\n'
# extract all paths to package-lock.json files
PACKAGE_LOCK_REGEX="(^package-lock\.json)"
PACKAGES=$(git diff --name-only HEAD^1 HEAD | grep -E $PACKAGE_LOCK_REGEX || true)

if [[ ${PACKAGES[@]} ]]; then
for package in $PACKAGES; do
echo "📦 $package was changed."
done
echo "📦 Running npm install to update your dependencies..."
npm install
else
echo "📦 All packages up-to-date. No need to run npm install."
fi
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run docs
git update-index --add docs/dist/documentation.md
npx --no lint-staged

0 comments on commit 45d29e8

Please sign in to comment.