From c0e6d8f332a7c9aee131c519378b754f479d46ee Mon Sep 17 00:00:00 2001 From: Olivier Martin DTSI/DSI Date: Wed, 3 Aug 2016 12:49:33 +0200 Subject: [PATCH] [Fix] make `nvm use` display `.nvmrc`'s version in output messages Set $PROVIDED_VERSION equals to $NVM_RC_VERSION only if a .nvmrc file is present and the user didn't provided a version to use (.ie typed `nvm use`). - Behavior before this fix : nvm use Found '.nvmrc' with version N/A: version "N/A" is not yet installed. You need to run "nvm install N/A" to install it before using it. - Behavior after this fix : nvm use Found '.nvmrc' with version N/A: version "v0.10.28" is not yet installed. You need to run "nvm install v0.10.28" to install it before using it. --- nvm.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nvm.sh b/nvm.sh index 297f5ff..93146da 100644 --- a/nvm.sh +++ b/nvm.sh @@ -486,6 +486,11 @@ nvm_ensure_version_installed() { LOCAL_VERSION="$(nvm_version "${PROVIDED_VERSION}")" EXIT_CODE="$?" local NVM_VERSION_DIR + + if [ "_$PROVIDED_VERSION" = "_N/A" ] && [ ! -d "$NVM_RC_VERSION" ] ; then + PROVIDED_VERSION="$(nvm_ensure_version_prefix "$NVM_RC_VERSION")" + fi + if [ "${EXIT_CODE}" != "0" ] || ! nvm_is_version_installed "${LOCAL_VERSION}"; then if VERSION="$(nvm_resolve_alias "${PROVIDED_VERSION}")"; then nvm_err "N/A: version \"${PROVIDED_VERSION} -> ${VERSION}\" is not yet installed."