From b0d6c05d6eefdac590bdf39caf3750150d8ec16a Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 13 Jan 2015 14:19:58 -0800 Subject: [PATCH] Make `nvm ls-remote iojs [foo]` only show iojs versions, and `nvm ls-remote node [foo]` only show node versions. --- nvm.sh | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/nvm.sh b/nvm.sh index f81c7b7..23e82dd 100644 --- a/nvm.sh +++ b/nvm.sh @@ -1115,17 +1115,33 @@ nvm() { return $NVM_LS_EXIT_CODE ;; "ls-remote" | "list-remote" ) - local NVM_LS_REMOTE_OUTPUT - local NVM_LS_REMOTE_EXIT_CODE - NVM_LS_REMOTE_OUTPUT=$(nvm_ls_remote "$2") - NVM_LS_REMOTE_EXIT_CODE=$? - nvm_print_versions "$NVM_LS_REMOTE_OUTPUT" + local PATTERN + PATTERN="$2" + local NVM_FLAVOR + case "_$PATTERN" in + "_$(nvm_iojs_prefix)" | "_$(nvm_node_prefix)" ) + NVM_FLAVOR="$PATTERN" + PATTERN="$3" + ;; + esac + + local NVM_LS_REMOTE_EXIT_CODE + NVM_LS_REMOTE_EXIT_CODE=0 + if [ "_$NVM_FLAVOR" != "_$(nvm_iojs_prefix)" ]; then + local NVM_LS_REMOTE_OUTPUT + NVM_LS_REMOTE_OUTPUT=$(nvm_ls_remote "$PATTERN") + NVM_LS_REMOTE_EXIT_CODE=$? + nvm_print_versions "$NVM_LS_REMOTE_OUTPUT" + fi - local NVM_LS_REMOTE_IOJS_OUTPUT local NVM_LS_REMOTE_IOJS_EXIT_CODE - NVM_LS_REMOTE_IOJS_OUTPUT=$(nvm_ls_remote_iojs "$2") - NVM_LS_REMOTE_IOJS_EXIT_CODE=$? - nvm_print_versions "$NVM_LS_REMOTE_IOJS_OUTPUT" + NVM_LS_REMOTE_IOJS_EXIT_CODE=0 + if [ "_$NVM_FLAVOR" != "_$(nvm_node_prefix)" ]; then + local NVM_LS_REMOTE_IOJS_OUTPUT + NVM_LS_REMOTE_IOJS_OUTPUT=$(nvm_ls_remote_iojs "$PATTERN") + NVM_LS_REMOTE_IOJS_EXIT_CODE=$? + nvm_print_versions "$NVM_LS_REMOTE_IOJS_OUTPUT" + fi return $NVM_LS_REMOTE_EXIT_CODE && $NVM_LS_REMOTE_IOJS_EXIT_CODE ;;