[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 <v0.10.28>
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 <v0.10.28>
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.
This commit is contained in:
Olivier Martin DTSI/DSI 2016-08-03 12:49:33 +02:00 committed by Jordan Harband
parent 59b0b3942c
commit c0e6d8f332
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56

5
nvm.sh
View File

@ -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."