mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-04 17:02:48 +08:00
Improve uninstall error message for missing versions
Include the requested version in the uninstall error output when the target is not installed. Add a fast test to lock the behavior. Close #3767
This commit is contained in:
8
nvm.sh
8
nvm.sh
@@ -3750,7 +3750,13 @@ nvm() {
|
||||
fi
|
||||
|
||||
if ! nvm_is_version_installed "${VERSION}"; then
|
||||
nvm_err "${VERSION} version is not installed..."
|
||||
local REQUESTED_VERSION
|
||||
REQUESTED_VERSION="${PATTERN}"
|
||||
if [ "_${VERSION}" != "_N/A" ] && [ "_${VERSION}" != "_${PATTERN}" ]; then
|
||||
nvm_err "Version '${VERSION}' (inferred from ${PATTERN}) is not installed."
|
||||
else
|
||||
nvm_err "Version '${REQUESTED_VERSION}' is not installed."
|
||||
fi
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
\. ../../nvm.sh
|
||||
\. ../common.sh
|
||||
|
||||
VERSION='v0.0.1'
|
||||
PATTERN='0.0'
|
||||
|
||||
mkdir -p "${NVM_DIR}/${VERSION}"
|
||||
|
||||
set +ex # needed for stderr
|
||||
RETURN_MESSAGE="$(nvm uninstall "${PATTERN}" 2>&1 || echo)"
|
||||
set -ex
|
||||
EXPECTED_MESSAGE="Version '${VERSION}' (inferred from ${PATTERN}) is not installed."
|
||||
|
||||
[ "${RETURN_MESSAGE}" = "${EXPECTED_MESSAGE}" ]
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
\. ../../nvm.sh
|
||||
\. ../common.sh
|
||||
|
||||
set +ex # needed for stderr
|
||||
RETURN_MESSAGE="$(nvm uninstall 22 2>&1 || echo)"
|
||||
set -ex
|
||||
EXPECTED_MESSAGE="Version '22' is not installed."
|
||||
|
||||
[ "${RETURN_MESSAGE}" = "${EXPECTED_MESSAGE}" ]
|
||||
@@ -5,7 +5,6 @@ set -x
|
||||
\. ../../nvm.sh
|
||||
|
||||
cleanup() { rm -f .nvmrc; }
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
NVM_TEST_VERSION=v0.42
|
||||
|
||||
Reference in New Issue
Block a user