[performance] `nvm_auto`: only call `nvm_ls_current` in `use` mode

Michael Potter 2020-08-19 11:40:45 -07:00 committed by Jordan Harband
parent 19c55b9936
commit f7fbad2bd6
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 2 additions and 2 deletions

4
nvm.sh
View File

@ -3788,11 +3788,10 @@ nvm_supports_xz() {
} }
nvm_auto() { nvm_auto() {
local NVM_CURRENT
NVM_CURRENT="$(nvm_ls_current)"
local NVM_MODE local NVM_MODE
NVM_MODE="${1-}" NVM_MODE="${1-}"
local VERSION local VERSION
local NVM_CURRENT
if [ "_${NVM_MODE}" = '_install' ]; then if [ "_${NVM_MODE}" = '_install' ]; then
VERSION="$(nvm_alias default 2>/dev/null || nvm_echo)" VERSION="$(nvm_alias default 2>/dev/null || nvm_echo)"
if [ -n "${VERSION}" ]; then if [ -n "${VERSION}" ]; then
@ -3801,6 +3800,7 @@ nvm_auto() {
nvm install >/dev/null nvm install >/dev/null
fi fi
elif [ "_$NVM_MODE" = '_use' ]; then elif [ "_$NVM_MODE" = '_use' ]; then
NVM_CURRENT="$(nvm_ls_current)"
if [ "_${NVM_CURRENT}" = '_none' ] || [ "_${NVM_CURRENT}" = '_system' ]; then if [ "_${NVM_CURRENT}" = '_none' ] || [ "_${NVM_CURRENT}" = '_system' ]; then
VERSION="$(nvm_resolve_local_alias default 2>/dev/null || nvm_echo)" VERSION="$(nvm_resolve_local_alias default 2>/dev/null || nvm_echo)"
if [ -n "${VERSION}" ]; then if [ -n "${VERSION}" ]; then