[Perf] nvm_ls: only look for a system node when the pattern can list it
`nvm_ls` lists the system version only for an empty pattern, `v`, or `system`, but it checked for a system node/io.js for every pattern. Each check runs `nvm deactivate` in a subshell, and a found system node also runs `node -v`. So every partial-version lookup, like resolving a `default` alias of `24` on shell startup, did that work and discarded it. Refs #3425, #3416. Signed-off-by: Wei-Lun Li <b84330808@gmail.com>
This commit is contained in:
1 parent
e759a03ee4
commit
a2c0ebaec1
2 files changed
+70
-6
No files matched your search
@@ -2543,9 +2543,14 @@ nvm_ls() {
|
||||
if nvm_is_iojs_version "${PATTERN}"; then
|
||||
NVM_DIRS_TO_SEARCH1="${NVM_VERSION_DIR_IOJS}"
|
||||
PATTERN="$(nvm_strip_iojs_prefix "${PATTERN}")"
|
||||
if nvm_has_system_iojs; then
|
||||
NVM_ADD_SYSTEM=true
|
||||
fi
|
||||
# only these patterns list the system version, at the end of this function
|
||||
case "${PATTERN}" in
|
||||
'' | v | system)
|
||||
if nvm_has_system_iojs; then
|
||||
NVM_ADD_SYSTEM=true
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
elif [ "${PATTERN}" = "${NVM_NODE_PREFIX}-" ]; then
|
||||
NVM_DIRS_TO_SEARCH1="${NVM_VERSION_DIR_OLD}"
|
||||
NVM_DIRS_TO_SEARCH2="${NVM_VERSION_DIR_NEW}"
|
||||
@@ -2557,9 +2562,14 @@ nvm_ls() {
|
||||
NVM_DIRS_TO_SEARCH1="${NVM_VERSION_DIR_OLD}"
|
||||
NVM_DIRS_TO_SEARCH2="${NVM_VERSION_DIR_NEW}"
|
||||
NVM_DIRS_TO_SEARCH3="${NVM_VERSION_DIR_IOJS}"
|
||||
if nvm_has_system_iojs || nvm_has_system_node; then
|
||||
NVM_ADD_SYSTEM=true
|
||||
fi
|
||||
# only these patterns list the system version, at the end of this function
|
||||
case "${PATTERN}" in
|
||||
'' | v | system)
|
||||
if nvm_has_system_iojs || nvm_has_system_node; then
|
||||
NVM_ADD_SYSTEM=true
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if ! [ -d "${NVM_DIRS_TO_SEARCH1}" ] || ! (command ls -1q "${NVM_DIRS_TO_SEARCH1}" | nvm_grep -q .); then
|
||||
|
||||
Reference in new issue
Block a user