[Refactor] `nvm_ls_remote_index_tab`: clean up to use `nvm_get_mirror`
parent
dca0220275
commit
3b5f088e01
35
nvm.sh
35
nvm.sh
|
@ -903,48 +903,60 @@ nvm_ls_remote() {
|
||||||
else
|
else
|
||||||
PATTERN=".*"
|
PATTERN=".*"
|
||||||
fi
|
fi
|
||||||
NVM_LTS="${NVM_LTS-}" nvm_ls_remote_index_tab node std "${NVM_NODEJS_ORG_MIRROR}" "${PATTERN}"
|
NVM_LTS="${NVM_LTS-}" nvm_ls_remote_index_tab node std "${PATTERN}"
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_ls_remote_iojs() {
|
nvm_ls_remote_iojs() {
|
||||||
NVM_LTS="${NVM_LTS-}" nvm_ls_remote_index_tab iojs std "${NVM_IOJS_ORG_MIRROR}" "${1-}"
|
NVM_LTS="${NVM_LTS-}" nvm_ls_remote_index_tab iojs std "${1-}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args flavor, type, version
|
||||||
nvm_ls_remote_index_tab() {
|
nvm_ls_remote_index_tab() {
|
||||||
local LTS
|
local LTS
|
||||||
LTS="${NVM_LTS-}"
|
LTS="${NVM_LTS-}"
|
||||||
if [ "$#" -lt 4 ]; then
|
if [ "$#" -lt 3 ]; then
|
||||||
nvm_err 'not enough arguments'
|
nvm_err 'not enough arguments'
|
||||||
return 5
|
return 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local FLAVOR
|
||||||
|
FLAVOR="${1-}"
|
||||||
|
|
||||||
local TYPE
|
local TYPE
|
||||||
TYPE="${1-}"
|
TYPE="${2-}"
|
||||||
|
|
||||||
|
local MIRROR
|
||||||
|
MIRROR="$(nvm_get_mirror "${FLAVOR}" "${TYPE}")"
|
||||||
|
if [ -z "${MIRROR}" ]; then
|
||||||
|
return 3
|
||||||
|
fi
|
||||||
|
|
||||||
local PREFIX
|
local PREFIX
|
||||||
PREFIX=''
|
PREFIX=''
|
||||||
case "${TYPE}-${2-}" in
|
case "${FLAVOR}-${TYPE}" in
|
||||||
iojs-std) PREFIX="$(nvm_iojs_prefix)-" ;;
|
iojs-std) PREFIX="$(nvm_iojs_prefix)-" ;;
|
||||||
node-std) PREFIX='' ;;
|
node-std) PREFIX='' ;;
|
||||||
iojs-*)
|
iojs-*)
|
||||||
nvm_err 'unknown type of io.js release'
|
nvm_err 'unknown type of io.js release'
|
||||||
return 4
|
return 4
|
||||||
;;
|
;;
|
||||||
node-*)
|
*)
|
||||||
nvm_err 'unknown type of node.js release'
|
nvm_err 'unknown type of node.js release'
|
||||||
return 4
|
return 4
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
local SORT_COMMAND
|
local SORT_COMMAND
|
||||||
SORT_COMMAND='sort'
|
SORT_COMMAND='sort'
|
||||||
case "${TYPE}" in
|
case "${FLAVOR}" in
|
||||||
node) SORT_COMMAND='sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n' ;;
|
node) SORT_COMMAND='sort -t. -u -k 1.2,1n -k 2,2n -k 3,3n' ;;
|
||||||
esac
|
esac
|
||||||
local MIRROR
|
|
||||||
MIRROR="${3-}"
|
|
||||||
local PATTERN
|
local PATTERN
|
||||||
PATTERN="${4-}"
|
PATTERN="${3-}"
|
||||||
|
|
||||||
local VERSIONS
|
local VERSIONS
|
||||||
if [ -n "${PATTERN}" ]; then
|
if [ -n "${PATTERN}" ]; then
|
||||||
if [ "${TYPE}" = 'iojs' ]; then
|
if [ "${FLAVOR}" = 'iojs' ]; then
|
||||||
PATTERN="$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "${PATTERN}")")"
|
PATTERN="$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "${PATTERN}")")"
|
||||||
else
|
else
|
||||||
PATTERN="$(nvm_ensure_version_prefix "${PATTERN}")"
|
PATTERN="$(nvm_ensure_version_prefix "${PATTERN}")"
|
||||||
|
@ -952,6 +964,7 @@ nvm_ls_remote_index_tab() {
|
||||||
else
|
else
|
||||||
unset PATTERN
|
unset PATTERN
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ZSH_HAS_SHWORDSPLIT_UNSET=1
|
ZSH_HAS_SHWORDSPLIT_UNSET=1
|
||||||
if nvm_has "setopt"; then
|
if nvm_has "setopt"; then
|
||||||
ZSH_HAS_SHWORDSPLIT_UNSET="$(set +e ; setopt | nvm_grep shwordsplit > /dev/null ; nvm_echo $?)"
|
ZSH_HAS_SHWORDSPLIT_UNSET="$(set +e ; setopt | nvm_grep shwordsplit > /dev/null ; nvm_echo $?)"
|
||||||
|
|
Loading…
Reference in New Issue