Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task/912 ensure mcdev collaborators auto update their dependencies on git pull #913

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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