mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-05 01:12:52 +08:00
[Fix] Reject bare LTS codenames in nvm install
Previously, `nvm install Argon` would succeed by matching the LTS name in the version description (e.g., "v4.9.1 (Latest LTS: Argon)"), but `nvm uninstall Argon` would fail because "Argon" is not a valid alias or not a valid version. Changes: - Added pattern matching check in nvm_remote_version (nvm.sh:785-791) - Skips check for implicit aliases (node, stable, etc.) to preserve existing functionality - Added unit tests to verify LTS names are rejected while version numbers still work After this fix: - `nvm install Argon` → fails (use `nvm install lts/argon` instead) - `nvm install 4` → still works - `nvm install node` → still works - `nvm install lts/argon` → still works This makes install and uninstall behavior consistent. Fixes #3474.
This commit is contained in:
committed by
Jordan Harband
parent
26066c10f4
commit
81f13638d7
9
nvm.sh
9
nvm.sh
@@ -781,6 +781,15 @@ nvm_remote_version() {
|
||||
else
|
||||
VERSION="$(NVM_LTS="${NVM_LTS-}" nvm_remote_versions "${PATTERN}" | command tail -1)"
|
||||
fi
|
||||
|
||||
if [ -n "${PATTERN}" ] && [ "_${VERSION}" != "_N/A" ] && ! nvm_validate_implicit_alias "${PATTERN}" 2>/dev/null; then
|
||||
local VERSION_NUM
|
||||
VERSION_NUM="$(nvm_echo "${VERSION}" | command awk '{print $1}')"
|
||||
if ! nvm_echo "${VERSION_NUM}" | nvm_grep -q "${PATTERN}"; then
|
||||
VERSION='N/A'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${NVM_VERSION_ONLY-}" ]; then
|
||||
command awk 'BEGIN {
|
||||
n = split(ARGV[1], a);
|
||||
|
||||
Reference in New Issue
Block a user