From 2245e3a8b9ff209e63fc37382a4b5c5ca97f3f72 Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 26 Nov 2024 15:13:01 -0500 Subject: [PATCH 1/3] Add sudo to yarn remove and test --- .circleci/test-deploy.yml | 14 +++++++++++++- src/scripts/install-yarn.sh | 10 +++++----- src/scripts/packages/yarn-berry-install.sh | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/.circleci/test-deploy.yml b/.circleci/test-deploy.yml index c5fff96..e6233af 100644 --- a/.circleci/test-deploy.yml +++ b/.circleci/test-deploy.yml @@ -91,6 +91,14 @@ jobs: exit 1 fi + integration-test-override-yarn: + docker: + - image: cimg/ruby:3.3.5-browsers + steps: + - node/install: + install-yarn: true + node-version: '22.11.0' + integration-test-use-nvmrc-version: parameters: os: @@ -213,7 +221,10 @@ jobs: workflows: test-deploy: jobs: - - integration-test-reinstall-yarn + - integration-test-override-yarn: + filters: *filters + - integration-test-reinstall-yarn: + filters: *filters - integration-test-install-specified-version: filters: *filters matrix: @@ -435,6 +446,7 @@ workflows: - integration-test-pnpm - integration-test-reinstall-yarn - node-yarn-mocha-with-test-result-path-job + - integration-test-override-yarn - node-yarn-mocha-test-job - node-yarn-jest-test-job - node-test-results-file-job diff --git a/src/scripts/install-yarn.sh b/src/scripts/install-yarn.sh index f7dd60d..02b1baa 100644 --- a/src/scripts/install-yarn.sh +++ b/src/scripts/install-yarn.sh @@ -23,21 +23,21 @@ installation_check () { echo "A different version of Yarn is installed ($(yarn --version)); removing it" if uname -a | grep Darwin > /dev/null 2>&1; then - brew uninstall yarn > /dev/null 2>&1 + $SUDO brew uninstall yarn > /dev/null 2>&1 elif grep Alpine /etc/issue > /dev/null 2>&1; then - apk del yarn > /dev/null 2>&1 + $SUDO apk del yarn > /dev/null 2>&1 elif grep Debian /etc/issue > /dev/null 2>&1; then $SUDO apt-get remove yarn > /dev/null 2>&1 && \ $SUDO apt-get purge yarn > /dev/null 2>&1 OLD_YARN=$(which yarn) - rm "$OLD_YARN" + $SUDO rm "$OLD_YARN" elif grep Ubuntu /etc/issue > /dev/null 2>&1; then $SUDO apt-get remove yarn > /dev/null 2>&1 && \ $SUDO apt-get purge yarn > /dev/null 2>&1 OLD_YARN=$(which yarn) - rm "$OLD_YARN" + $SUDO rm "$OLD_YARN" elif command -v yum > /dev/null 2>&1; then - yum remove yarn > /dev/null 2>&1 + $SUDO yum remove yarn > /dev/null 2>&1 fi $SUDO rm -rf "$HOME/.yarn" > /dev/null 2>&1 diff --git a/src/scripts/packages/yarn-berry-install.sh b/src/scripts/packages/yarn-berry-install.sh index 2efe419..fc70f19 100644 --- a/src/scripts/packages/yarn-berry-install.sh +++ b/src/scripts/packages/yarn-berry-install.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash +if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi if ! corepack enable; then echo "Using alternative corepack location" corepack enable --install-directory ~/bin From e7b4a09a26802291671d033f1028292b4ec9e60b Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 26 Nov 2024 15:25:12 -0500 Subject: [PATCH 2/3] Update sudo to rm --- src/scripts/install-yarn.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scripts/install-yarn.sh b/src/scripts/install-yarn.sh index 02b1baa..565764b 100644 --- a/src/scripts/install-yarn.sh +++ b/src/scripts/install-yarn.sh @@ -23,9 +23,9 @@ installation_check () { echo "A different version of Yarn is installed ($(yarn --version)); removing it" if uname -a | grep Darwin > /dev/null 2>&1; then - $SUDO brew uninstall yarn > /dev/null 2>&1 + brew uninstall yarn > /dev/null 2>&1 elif grep Alpine /etc/issue > /dev/null 2>&1; then - $SUDO apk del yarn > /dev/null 2>&1 + apk del yarn > /dev/null 2>&1 elif grep Debian /etc/issue > /dev/null 2>&1; then $SUDO apt-get remove yarn > /dev/null 2>&1 && \ $SUDO apt-get purge yarn > /dev/null 2>&1 @@ -37,7 +37,7 @@ installation_check () { OLD_YARN=$(which yarn) $SUDO rm "$OLD_YARN" elif command -v yum > /dev/null 2>&1; then - $SUDO yum remove yarn > /dev/null 2>&1 + yum remove yarn > /dev/null 2>&1 fi $SUDO rm -rf "$HOME/.yarn" > /dev/null 2>&1 From 8104595c44460dba75f8da82d835b2de991d06eb Mon Sep 17 00:00:00 2001 From: Mateo Arboleda Date: Tue, 26 Nov 2024 15:42:53 -0500 Subject: [PATCH 3/3] Remove useless line --- src/scripts/packages/yarn-berry-install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/scripts/packages/yarn-berry-install.sh b/src/scripts/packages/yarn-berry-install.sh index fc70f19..2efe419 100644 --- a/src/scripts/packages/yarn-berry-install.sh +++ b/src/scripts/packages/yarn-berry-install.sh @@ -1,5 +1,4 @@ #!/usr/bin/env bash -if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi if ! corepack enable; then echo "Using alternative corepack location" corepack enable --install-directory ~/bin