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] ensure mcdev collaborators auto-update their dependencies on git pull #912

Closed
JoernBerkefeld opened this issue May 17, 2023 · 1 comment · Fixed by #913
Closed
Assignees
Labels
chore Jira issue-type "Task"
Milestone

Comments

@JoernBerkefeld
Copy link
Contributor

JoernBerkefeld commented May 17, 2023

similar solution to what #894 will require for mcdev users:

how to

From: https://dev.to/zirkelc/automatically-install-npm-dependencies-on-git-pull-bg0

The following file is going to be executed by Husky as post-merge hook.

#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

IFS=$'\n'
# 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)"
# extract all paths to package-lock.json files 
PACKAGES=("$(git diff --name-only HEAD@{1} HEAD | grep -E "$PACKAGE_LOCK_REGEX")")

if [[ ${PACKAGES[@]} ]]; then
  for package in $PACKAGES; do
    echo "📦 $package was changed. Running npm install to update your dependencies..."
    DIR=$(dirname package)
    cd "$DIR" && npm install
  done
fi

The file must be saved as post-merge (no .sh extension) inside the .husky folder. I'm running on macOS with zsh as default shell (see shebang #!/bin/zsh) and it's working. However, I didn't test it with bash, so there might be some changes necessary if you run a different shell.


Note: I'm thinking we should also run this on post-checkout

@JoernBerkefeld JoernBerkefeld added the chore Jira issue-type "Task" label May 17, 2023
@JoernBerkefeld JoernBerkefeld added this to the 5.0.2 milestone May 17, 2023
@JoernBerkefeld JoernBerkefeld self-assigned this May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
JoernBerkefeld added a commit that referenced this issue May 17, 2023
@github-actions
Copy link

Closed by #913.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment