Removed handling of lts as an alias and modified error handling for nvm use lts

This commit is contained in:
Reetik Rajan 2024-10-05 10:07:46 +05:30
parent 9895f4b48c
commit d2e1836fcd

13
nvm.sh
View File

@ -700,10 +700,12 @@ nvm_ensure_version_installed() {
nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed." nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed."
fi fi
nvm_err "" nvm_err ""
if [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then if [ "${PROVIDED_VERSION}" = 'lts' ]; then
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it." nvm_err "You need to run \`nvm install --lts\` to install and \`nvm use --lts\` to use it."
else elif [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then
nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.' 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 fi
return 1 return 1
fi fi
@ -748,9 +750,6 @@ nvm_remote_version() {
"$(nvm_iojs_prefix)") "$(nvm_iojs_prefix)")
VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote_iojs | command tail -1)" &&: 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}")" &&: VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_ls_remote "${PATTERN}")" &&:
;; ;;