From 9895f4b48cf182150e5a38d81e98f86705878cd5 Mon Sep 17 00:00:00 2001 From: Reetik Rajan Date: Sat, 5 Oct 2024 09:21:42 +0530 Subject: [PATCH 1/2] Refactor nvm_remote_version to handle "lts" as a special case --- nvm.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nvm.sh b/nvm.sh index 9eeede2..d06bb9f 100755 --- a/nvm.sh +++ b/nvm.sh @@ -748,6 +748,9 @@ nvm_remote_version() { "$(nvm_iojs_prefix)") VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote_iojs | command tail -1)" &&: ;; + "lts") + VERSION="$(NVM_LTS="lts/*" nvm_ls_remote | command tail -1)" &&: + ;; *) VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote "${PATTERN}")" &&: ;; From d2e1836fcd2314e56a8cfa414842853424926e7a Mon Sep 17 00:00:00 2001 From: Reetik Rajan Date: Sat, 5 Oct 2024 10:07:46 +0530 Subject: [PATCH 2/2] Removed handling of lts as an alias and modified error handling for `nvm use lts` --- nvm.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/nvm.sh b/nvm.sh index d06bb9f..c28c5b5 100755 --- a/nvm.sh +++ b/nvm.sh @@ -700,10 +700,12 @@ nvm_ensure_version_installed() { nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed." fi nvm_err "" - if [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then - nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it." - else - nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.' + if [ "${PROVIDED_VERSION}" = 'lts' ]; then + nvm_err "You need to run \`nvm install --lts\` to install and \`nvm use --lts\` to use it." + elif [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then + nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it." + else + nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.' fi return 1 fi @@ -748,9 +750,6 @@ nvm_remote_version() { "$(nvm_iojs_prefix)") VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote_iojs | command tail -1)" &&: ;; - "lts") - VERSION="$(NVM_LTS="lts/*" nvm_ls_remote | command tail -1)" &&: - ;; *) VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote "${PATTERN}")" &&: ;;