Rename nvm_ls_remote_iojs_org → nvm_ls_remote_index_tab and make it generic.

Jordan Harband 2015-10-17 10:19:39 -07:00
parent b5e0603e64
commit 690543d6ad
1 changed files with 27 additions and 14 deletions

41
nvm.sh
View File

@ -700,34 +700,47 @@ nvm_ls_remote() {
} }
nvm_ls_remote_iojs() { nvm_ls_remote_iojs() {
nvm_ls_remote_iojs_org std "$NVM_IOJS_ORG_MIRROR" "$1" nvm_ls_remote_index_tab iojs std "$NVM_IOJS_ORG_MIRROR" "$1"
} }
nvm_ls_remote_iojs_org() { nvm_ls_remote_index_tab() {
local PREFIX if [ "$#" -lt 4 ]; then
if [ "_$1" = "_std" ]; then echo "not enough arguments" >&2
PREFIX="$(nvm_iojs_prefix)" return 5
else
echo "unknown type of io.js release" >&2
return 4
fi fi
local TYPE
TYPE="$1"
local PREFIX
case "$TYPE-$2" in
iojs-std) PREFIX="$(nvm_iojs_prefix)-" ;;
iojs-*)
echo "unknown type of io.js release" >&2
return 4
;;
esac
local SORT_COMMAND
SORT_COMMAND='sort'
local MIRROR local MIRROR
MIRROR="$2" MIRROR="$3"
local PATTERN local PATTERN
PATTERN="$3" PATTERN="$4"
local VERSIONS local VERSIONS
if [ -n "$PATTERN" ]; then if [ -n "$PATTERN" ]; then
PATTERN="$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "$PATTERN")")" if [ "_$TYPE" = "_iojs" ]; then
PATTERN="$(nvm_ensure_version_prefix "$(nvm_strip_iojs_prefix "$PATTERN")")"
else
PATTERN="$(nvm_ensure_version_prefix "$PATTERN")"
fi
else else
PATTERN=".*" PATTERN=".*"
fi fi
VERSIONS="$(nvm_download -L -s "$MIRROR/index.tab" -o - \ VERSIONS="$(nvm_download -L -s "$MIRROR/index.tab" -o - \
| command sed " | command sed "
1d; 1d;
s/^/$PREFIX-/; s/^/$PREFIX/;
s/[[:blank:]].*//" \ s/[[:blank:]].*//" \
| command grep -w "$PATTERN" \ | command grep -w "$PATTERN" \
| command sort)" | $SORT_COMMAND)"
if [ -z "$VERSIONS" ]; then if [ -z "$VERSIONS" ]; then
echo "N/A" echo "N/A"
return 3 return 3
@ -2210,7 +2223,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | command grep -v "N/A" | command sed '/^$/d'
nvm_iojs_prefix nvm_node_prefix \ nvm_iojs_prefix nvm_node_prefix \
nvm_add_iojs_prefix nvm_strip_iojs_prefix \ nvm_add_iojs_prefix nvm_strip_iojs_prefix \
nvm_is_iojs_version nvm_is_alias \ nvm_is_iojs_version nvm_is_alias \
nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_iojs_org \ nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab \
nvm_ls nvm_remote_version nvm_remote_versions \ nvm_ls nvm_remote_version nvm_remote_versions \
nvm_install_iojs_binary nvm_install_node_binary \ nvm_install_iojs_binary nvm_install_node_binary \
nvm_install_node_source \ nvm_install_node_source \