[Perf] nvm_is_installed_exact_version: also take the fast path for an exact prerelease

An installed prerelease, like `v24.0.0-rc.1`, now resolves to itself without the `nvm_ls` pipeline, as releases already do.
This commit is contained in:
Jordan Harband committed 2026-10-21 13:09:25 -07:00
1 parent fe2900d176
commit 11df5ed6f1
3 files changed
+27 -3

No files matched your search

@@ -46,10 +46,21 @@ for VERSION in 'v12.0.0.0' 'v12.0.0.' 'v12..0' 'v.12.0' 'v12.0'; do
done
# anything that is not an exact vX.Y.Z fails, even if it would resolve to an installed version
for VERSION in '12.0.0' '12' 'v12' 'v12.0' 'v12.0.0-rc.1' 'node' 'stable' 'lts/*' 'iojs-v1.0.0' 'system' 'default'; do
for VERSION in '12.0.0' '12' 'v12' 'v12.0' 'node' 'stable' 'lts/*' 'iojs-v1.0.0' 'system' 'default'; do
! nvm_is_installed_exact_version "$VERSION" || die "$VERSION is not an exact version and should fail"
done
# an exact, installed prerelease succeeds, but a malformed one fails, even when installed
for VERSION in 'v12.0.0-rc.1' 'v12.0.0-' 'v12.0.0-.x' 'v12.0.0-a..b' 'v12.0.0-rc.'; do
mkdir -p "$NODE_PATH/$VERSION/bin"
touch "$NODE_PATH/$VERSION/bin/node"
chmod +x "$NODE_PATH/$VERSION/bin/node"
done
nvm_is_installed_exact_version 'v12.0.0-rc.1' || die 'v12.0.0-rc.1 is installed and should succeed'
for VERSION in 'v12.0.0-' 'v12.0.0-.x' 'v12.0.0-a..b' 'v12.0.0-rc.'; do
! nvm_is_installed_exact_version "$VERSION" || die "$VERSION is not an exact version and should fail, even when installed"
done
# an alias with the exact same name takes precedence, so the fast path must not apply
mkdir -p "$(nvm_alias_path)"
echo 'v12.0.0' > "$(nvm_alias_path)/v12.0.0"