Skip to content
Myr

[Perf] `nvm_resolve_local_alias`: skip `nvm_version` for an exact, installed version

Before adoption: this commit came in with the history the project adopted, so no landing records it.

See #3416

authored by Hridhin Varkey Joseph · committed by Jordan Harband · parent f1f3d46 · Browse files · 2 files+30 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+30 added−3 removed

  • tests:+20 added−0 removed
  • other:+10 added−3 removed

2 files+30 added−3 removed

added:test/fast/Aliases/nvm_resolve_local_alias skips nvm_version for an exact installed version+20 added
1#!/bin/sh23die () { echo "$@" ; exit 1; }45: nvm.sh6\. ../../../nvm.sh78nvm_version() {9 echo 'nvm_version was called' >&210 return 4211}1213EXACT="$(nvm_resolve_local_alias test-stable-1)"14[ "_$EXACT" = "_v0.0.1" ] || die "'nvm_resolve_local_alias test-stable-1' was not v0.0.1; got $EXACT"1516echo v0.0.99 > ../../../alias/test-not-installed17NOT_INSTALLED="$(nvm_resolve_local_alias test-not-installed 2>/dev/null)"18EXIT_CODE=$?19rm -f ../../../alias/test-not-installed20[ "_$EXIT_CODE" = "_42" ] || die "an exact version that is not installed should still go through nvm_version; got exit code $EXIT_CODE"
modified:nvm.sh+10 added-3 removed
1671 unmodified lines
1672 EXIT_CODE=$?1673 if [ -z "${VERSION}" ]; then1674 return $EXIT_CODE1675 fi1676 if [ "_${VERSION}" != '_∞' ]; then1677 nvm_version "${VERSION}"1678 else1676 if [ "_${VERSION}" = '_∞' ]; then1677 nvm_echo "${VERSION}"1678 return1679 fi16801681 # Fast path: an exact, installed vX.Y.Z needs no further resolution.1682 if nvm_is_installed_exact_version "${VERSION}"; then1683 nvm_echo "${VERSION}"1684 return1685 fi16861687 nvm_version "${VERSION}"1688}16891690nvm_iojs_prefix() {1691 nvm_echo 'iojs'
3768 unmodified lines