mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-08-20 04:23:43 +00:00
Compare commits
4 Commits
2ed3a8fdce
...
ebdd5b2f53
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ebdd5b2f53 | ||
![]() |
5dc31ac51b | ||
![]() |
5f7d419458 | ||
![]() |
b42c165667 |
16
nvm.sh
16
nvm.sh
@ -700,10 +700,12 @@ nvm_ensure_version_installed() {
|
|||||||
nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed."
|
nvm_err "N/A: version \"${PREFIXED_VERSION:-$PROVIDED_VERSION}\" is not yet installed."
|
||||||
fi
|
fi
|
||||||
nvm_err ""
|
nvm_err ""
|
||||||
if [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then
|
if [ "${PROVIDED_VERSION}" = 'lts' ]; then
|
||||||
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it."
|
nvm_err '`lts` is not an alias - you may need to run `nvm install --lts` to install and `nvm use --lts` to use it.'
|
||||||
else
|
elif [ "${IS_VERSION_FROM_NVMRC}" != '1' ]; then
|
||||||
nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
|
nvm_err "You need to run \`nvm install ${PROVIDED_VERSION}\` to install and use it."
|
||||||
|
else
|
||||||
|
nvm_err 'You need to run `nvm install` to install and use the node version specified in `.nvmrc`.'
|
||||||
fi
|
fi
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
@ -4527,7 +4529,11 @@ nvm_supports_xz() {
|
|||||||
if [ "_${NVM_OS}" = '_darwin' ]; then
|
if [ "_${NVM_OS}" = '_darwin' ]; then
|
||||||
local MACOS_VERSION
|
local MACOS_VERSION
|
||||||
MACOS_VERSION="$(sw_vers -productVersion)"
|
MACOS_VERSION="$(sw_vers -productVersion)"
|
||||||
if nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then
|
if tar --version | command grep -q GNU && ! command which xz >/dev/null 2>&1; then
|
||||||
|
# On macOS with GNU tar in use, and no xv on the path, xv-compressed
|
||||||
|
# tarballs aren't supported
|
||||||
|
return 1
|
||||||
|
elif nvm_version_greater "10.9.0" "${MACOS_VERSION}"; then
|
||||||
# macOS 10.8 and earlier doesn't support extracting xz-compressed tarballs with tar
|
# macOS 10.8 and earlier doesn't support extracting xz-compressed tarballs with tar
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
19
test/slow/nvm use/Running 'nvm use lts' shows actionable error
Executable file
19
test/slow/nvm use/Running 'nvm use lts' shows actionable error
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
die () { echo "$@" ; exit 1; }
|
||||||
|
|
||||||
|
\. ../../../nvm.sh
|
||||||
|
|
||||||
|
# Deactivate any active node version
|
||||||
|
nvm deactivate >/dev/null 2>&1 || die 'deactivate failed'
|
||||||
|
|
||||||
|
# Attempt to use 'lts' without '--' and capture the error message
|
||||||
|
ERROR_OUTPUT=$(nvm use lts 2>&1) || true
|
||||||
|
|
||||||
|
EXPECTED_ERROR='`lts` is not an alias - you may need to run `nvm install --lts` to install and `nvm use --lts` to use it.'
|
||||||
|
|
||||||
|
# Check if the error message matches the expected output
|
||||||
|
echo "$ERROR_OUTPUT" | grep -q "$EXPECTED_ERROR" \
|
||||||
|
|| die "Expected error message not found. Got: $ERROR_OUTPUT"
|
Loading…
x
Reference in New Issue
Block a user