Skip to content

Commit

Permalink
Add nvm_get_mirror
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Aug 11, 2016
1 parent 9c65197 commit d3d768a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
13 changes: 12 additions & 1 deletion nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,17 @@ nvm_is_merged_node_version() {
nvm_version_greater_than_or_equal_to "$1" v4.0.0
}

nvm_get_mirror() {
case "${1}-${2}" in
node-std) nvm_echo "${NVM_NODEJS_ORG_MIRROR}" ;;
iojs-std) nvm_echo "${NVM_IOJS_ORG_MIRROR}" ;;
*)
nvm_err 'unknown type of node.js or io.js release'
return 1
;;
esac
}

nvm_install_merged_node_binary() {
local NVM_NODE_TYPE
NVM_NODE_TYPE="${1}"
Expand Down Expand Up @@ -2875,7 +2886,7 @@ $NVM_LS_REMOTE_POST_MERGED_OUTPUT" | nvm_grep -v "N/A" | command sed '/^$/d')"
nvm_ls_remote nvm_ls_remote_iojs nvm_ls_remote_index_tab \
nvm_ls nvm_remote_version nvm_remote_versions \
nvm_install_iojs_binary nvm_install_node_binary \
nvm_install_merged_node_binary \
nvm_install_merged_node_binary nvm_get_mirror \
nvm_install_node_source nvm_check_file_permissions \
nvm_get_checksum_alg \
nvm_version nvm_rc_version nvm_match_version \
Expand Down
16 changes: 16 additions & 0 deletions test/fast/Unit tests/nvm_get_mirror
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -ex

die () { echo $@ ; exit 1; }

. ../../../nvm.sh

! nvm_get_mirror || die 'unknown release type did not error'
! nvm_get_mirror node || die 'unknown release type did not error'
! nvm_get_mirror iojs || die 'unknown release type did not error'
! nvm_get_mirror node foo || die 'unknown release type did not error'
! nvm_get_mirror iojs foo || die 'unknown release type did not error'

[ "$(nvm_get_mirror node std)" = "${NVM_NODEJS_ORG_MIRROR}" ] || die 'node std did not yield NVM_NODEJS_ORG_MIRROR'
[ "$(nvm_get_mirror iojs std)" = "${NVM_IOJS_ORG_MIRROR}" ] || die 'node std did not yield NVM_NODEJS_ORG_MIRROR'

0 comments on commit d3d768a

Please sign in to comment.