diff --git a/nvm.sh b/nvm.sh index 67794cb..8d8133f 100644 --- a/nvm.sh +++ b/nvm.sh @@ -112,9 +112,10 @@ nvm_version_path() { local VERSION VERSION="$1" if [ -z "$VERSION" ]; then - echo "$NVM_DIR" + echo "version is required" >&2 + return 3 elif [ ! -z "$VERSION" ]; then - echo "$NVM_DIR/$VERSION" + echo "$(nvm_version_dir old)/$VERSION" fi } diff --git a/test/fast/Unit tests/nvm_version_path b/test/fast/Unit tests/nvm_version_path index adb6338..ba38e37 100755 --- a/test/fast/Unit tests/nvm_version_path +++ b/test/fast/Unit tests/nvm_version_path @@ -4,6 +4,6 @@ die () { echo $@ ; exit 1; } . ../../../nvm.sh -[ "$(nvm_version_path)" = "$NVM_DIR" ] && -[ "$(nvm_version_path foo)" = "$NVM_DIR/foo" ] +[ "$(nvm_version_path foo)" = "$NVM_DIR/foo" ] || die '"nvm_version_path foo" did not return correct location' +[ "$(nvm_version_path 2>&1)" = "version is required" ] || die '"nvm_version_path" did not error out'