From 94076359d518d255cc0ffb49f46396b2bc7d706c Mon Sep 17 00:00:00 2001 From: Alex Sanders Date: Tue, 2 Jan 2024 12:15:23 +0000 Subject: [PATCH] smooth the transition to pnpm in `post-merge` script --- .husky/post-merge | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/.husky/post-merge b/.husky/post-merge index 0791eed2c6b..a87191a93ea 100755 --- a/.husky/post-merge +++ b/.husky/post-merge @@ -4,18 +4,27 @@ RED='\033[0;31m' ENDCOLOR='\033[0m' +# Delete old yarn-based stuff while transitioning from yarn to pnpm. It can be +# removed once we're confident that pnpm is working. +if [ -d ".yarn" ]; then + echo "${RED}This application now uses pnpm. Cleaning up old yarn stuff...${ENDCOLOR}" + rm -rf .yarn + rm -rf **/node_modules # belt-and-braces +fi + changedFiles="$(git diff-tree -r --name-only --no-commit-id HEAD@{1} HEAD)" changedLock="$(echo "$changedFiles" | { grep -E 'pnpm-lock.yaml' || :; })" changedNode="$(echo "$changedFiles" | { grep '.nvmrc' || :; })" -if [[ ! -z $changedLock ]] +if [[ ! -z $changedNode ]] then - echo "${RED}This application has new dependencies. Running 'pnpm'... ${ENDCOLOR}" - pnpm install --frozen-lockfile + version="$(cat .nvmrc)" + echo "${RED}This project needs Node "$version". Please run 'nvm use', 'fnm use' or 'asdf install' (or whatever is appropriate) then run 'pnpm install --frozen-lockfile'${ENDCOLOR}" + exit 1 fi -if [[ ! -z $changedNode ]] +if [[ ! -z $changedLock ]] then - version="$(cat .nvmrc)" - echo "${RED}This project now uses node version "$version". Please use 'nvm use' & run 'pnpm install --frozen-lockfile'${ENDCOLOR}" + echo "${RED}This application has updated dependencies. Installing with pnpm...${ENDCOLOR}" + pnpm install --frozen-lockfile fi