mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-10-11 00:00:13 +08:00
[Perf] nvm_resolve_local_alias: skip nvm_version for an exact, installed version
See #3416
This commit is contained in:
@@ -1673,11 +1673,18 @@ nvm_resolve_local_alias() {
|
||||
if [ -z "${VERSION}" ]; then
|
||||
return $EXIT_CODE
|
||||
fi
|
||||
if [ "_${VERSION}" != '_∞' ]; then
|
||||
nvm_version "${VERSION}"
|
||||
else
|
||||
if [ "_${VERSION}" = '_∞' ]; then
|
||||
nvm_echo "${VERSION}"
|
||||
return
|
||||
fi
|
||||
|
||||
# Fast path: an exact, installed vX.Y.Z needs no further resolution.
|
||||
if nvm_is_installed_exact_version "${VERSION}"; then
|
||||
nvm_echo "${VERSION}"
|
||||
return
|
||||
fi
|
||||
|
||||
nvm_version "${VERSION}"
|
||||
}
|
||||
|
||||
nvm_iojs_prefix() {
|
||||
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
: nvm.sh
|
||||
\. ../../../nvm.sh
|
||||
|
||||
nvm_version() {
|
||||
echo 'nvm_version was called' >&2
|
||||
return 42
|
||||
}
|
||||
|
||||
EXACT="$(nvm_resolve_local_alias test-stable-1)"
|
||||
[ "_$EXACT" = "_v0.0.1" ] || die "'nvm_resolve_local_alias test-stable-1' was not v0.0.1; got $EXACT"
|
||||
|
||||
echo v0.0.99 > ../../../alias/test-not-installed
|
||||
NOT_INSTALLED="$(nvm_resolve_local_alias test-not-installed 2>/dev/null)"
|
||||
EXIT_CODE=$?
|
||||
rm -f ../../../alias/test-not-installed
|
||||
[ "_$EXIT_CODE" = "_42" ] || die "an exact version that is not installed should still go through nvm_version; got exit code $EXIT_CODE"
|
||||
Reference in New Issue
Block a user