From 3182be634e0767244d99ac7a61a534c97f8c9e20 Mon Sep 17 00:00:00 2001 From: Joe Previte Date: Wed, 7 Dec 2022 15:04:50 -0700 Subject: [PATCH] refactor: use npm in build steps and postinstall.sh (#5844) * refactor: default to npm in postinstall.sh yarn has a bug where it will try to update dependencies even if `yarn.lock` is present. Therefore we're defaulting to `npm` to prevent further issues. * refactor: exclude yarn.lock in standalone By excluding `yarn.lock`, we prevent issues where the user must use `yarn` instead of `npm` to install code-server. --- ci/build/build-standalone-release.sh | 2 +- ci/build/npm-postinstall.sh | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ci/build/build-standalone-release.sh b/ci/build/build-standalone-release.sh index a297b9044..12bda50be 100755 --- a/ci/build/build-standalone-release.sh +++ b/ci/build/build-standalone-release.sh @@ -10,7 +10,7 @@ main() { source ./ci/lib.sh - rsync "$RELEASE_PATH/" "$RELEASE_PATH-standalone" + rsync --exclude yarn.lock "$RELEASE_PATH/" "$RELEASE_PATH-standalone" RELEASE_PATH+=-standalone # We cannot find the path to node from $PATH because yarn shims a script to ensure diff --git a/ci/build/npm-postinstall.sh b/ci/build/npm-postinstall.sh index 7d5e13b02..dc457935e 100755 --- a/ci/build/npm-postinstall.sh +++ b/ci/build/npm-postinstall.sh @@ -127,14 +127,6 @@ install_with_yarn_or_npm() { # NOTE@edvincent: We want to keep using the package manager that the end-user was using to install the package. # This also ensures that when *we* run `yarn` in the development process, the yarn.lock file is used. case "${npm_config_user_agent-}" in - yarn*) - if [ -f "yarn.lock" ]; then - yarn --production --frozen-lockfile --no-default-rc - else - echo "yarn.lock file not present, not running in development mode. use npm to install code-server!" - exit 1 - fi - ;; npm*) if [ -f "yarn.lock" ]; then echo "yarn.lock file present, running in development mode. use yarn to install code-server!" @@ -146,6 +138,14 @@ install_with_yarn_or_npm() { npm install --unsafe-perm --legacy-peer-deps --omit=dev fi ;; + yarn*) + if [ -f "yarn.lock" ]; then + yarn --production --frozen-lockfile --no-default-rc + else + echo "yarn.lock file not present, not running in development mode. use npm to install code-server!" + exit 1 + fi + ;; *) echo "Could not determine which package manager is being used to install code-server" exit 1