Skip to content

Commit

Permalink
[Fix] stop setting mirror env vars unnecessarily
Browse files Browse the repository at this point in the history
  • Loading branch information
mceachen authored and ljharb committed Mar 17, 2017
1 parent 952d006 commit 1e6b5ce
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 14 deletions.
14 changes: 2 additions & 12 deletions nvm.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,6 @@ if [ -z "${NVM_DIR-}" ]; then
fi
unset NVM_SCRIPT_SOURCE 2> /dev/null


# Setup mirror location if not already set
if [ -z "${NVM_NODEJS_ORG_MIRROR-}" ]; then
export NVM_NODEJS_ORG_MIRROR="https://nodejs.org/dist"
fi

if [ -z "${NVM_IOJS_ORG_MIRROR-}" ]; then
export NVM_IOJS_ORG_MIRROR="https://iojs.org/dist"
fi

nvm_tree_contains_path() {
local tree
tree="${1-}"
Expand Down Expand Up @@ -1532,8 +1522,8 @@ nvm_is_merged_node_version() {

nvm_get_mirror() {
case "${1}-${2}" in
node-std) nvm_echo "${NVM_NODEJS_ORG_MIRROR}" ;;
iojs-std) nvm_echo "${NVM_IOJS_ORG_MIRROR}" ;;
node-std) nvm_echo "${NVM_NODEJS_ORG_MIRROR:-https://nodejs.org/dist}" ;;
iojs-std) nvm_echo "${NVM_IOJS_ORG_MIRROR:-https://iojs.org/dist}" ;;
*)
nvm_err 'unknown type of node.js or io.js release'
return 1
Expand Down
19 changes: 17 additions & 2 deletions test/fast/Unit tests/nvm_get_mirror
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set -ex

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

unset NVM_NODEJS_ORG_MIRROR
unset NVM_IOJS_ORG_MIRROR

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

! nvm_get_mirror || die 'unknown release type did not error'
Expand All @@ -12,5 +15,17 @@ die () { echo "$@" ; exit 1; }
! 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'
[ -z "$NVM_NODEJS_ORG_MIRROR" ] || die "MIRROR environment variables should not be exported"
[ -z "$NVM_IOJS_ORG_MIRROR" ] || die "MIRROR environment variables should not be exported"

[ "$(nvm_get_mirror node std)" = "https://nodejs.org/dist" ] || die "incorrect default node-std mirror"
[ "$(nvm_get_mirror iojs std)" = "https://iojs.org/dist" ] || die "incorrect default iojs-std mirror"

NVM_NODEJS_ORG_MIRROR="test://domain"
[ "$(nvm_get_mirror node std)" = "test://domain" ] || die "node-std mirror should respect NVM_NODEJS_ORG_MIRROR"
unset NVM_NODEJS_ORG_MIRROR

NVM_IOJS_ORG_MIRROR="test://domain"
[ "$(nvm_get_mirror iojs std)" = "test://domain" ] || die "iojs-std mirror should respect NVM_IOJS_ORG_MIRROR"
unset NVM_IOJS_ORG_MIRROR

0 comments on commit 1e6b5ce

Please sign in to comment.