From 8c036370238248fe127d2ec6aee16cc514e0aad3 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Mon, 14 Nov 2016 19:31:35 +0800 Subject: [PATCH] [Fix] `nvm install`: Handle 'N/A' version instead of asking to install it Fixes #1304. --- nvm.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 090043e..6e33d47 100755 --- a/nvm.sh +++ b/nvm.sh @@ -2626,10 +2626,14 @@ nvm() { fi return 8 fi - + if [ "${VERSION}" = 'N/A' ]; then + nvm_err "N/A: version \"${PROVIDED_VERSION} -> ${VERSION}\" is not yet installed." + nvm_err "" + nvm_err "You need to run \"nvm install ${PROVIDED_VERSION}\" to install it before using it." + return 3 # This nvm_ensure_version_installed call can be a performance bottleneck # on shell startup. Perhaps we can optimize it away or make it faster. - if ! nvm_ensure_version_installed "${VERSION}"; then + elif ! nvm_ensure_version_installed "${VERSION}"; then return $? fi