From f7fbad2bd6d2d117f265c2329abd6b4129dc606d Mon Sep 17 00:00:00 2001 From: Michael Potter Date: Wed, 19 Aug 2020 11:40:45 -0700 Subject: [PATCH] [performance] `nvm_auto`: only call `nvm_ls_current` in `use` mode --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 11a24fa..4a95dc5 100644 --- a/nvm.sh +++ b/nvm.sh @@ -3788,11 +3788,10 @@ nvm_supports_xz() { } nvm_auto() { - local NVM_CURRENT - NVM_CURRENT="$(nvm_ls_current)" local NVM_MODE NVM_MODE="${1-}" local VERSION + local NVM_CURRENT if [ "_${NVM_MODE}" = '_install' ]; then VERSION="$(nvm_alias default 2>/dev/null || nvm_echo)" if [ -n "${VERSION}" ]; then @@ -3801,6 +3800,7 @@ nvm_auto() { nvm install >/dev/null fi elif [ "_$NVM_MODE" = '_use' ]; then + NVM_CURRENT="$(nvm_ls_current)" if [ "_${NVM_CURRENT}" = '_none' ] || [ "_${NVM_CURRENT}" = '_system' ]; then VERSION="$(nvm_resolve_local_alias default 2>/dev/null || nvm_echo)" if [ -n "${VERSION}" ]; then