Skip to content

Commit 3350bf9

Browse files
committed
Introduce NODEJS_ORG_MIRROR and IOJS_ORG_MIRROR
Deprecate NVM_NODEJS_ORG_MIRROR and NVM_IOJS_ORG_MIRROR as they were only ever intended to be internal nvm environment variables. These will be removed in the next semver-major release.
1 parent d1e4cc4 commit 3350bf9

File tree

3 files changed

+162
-9
lines changed

3 files changed

+162
-9
lines changed

lib/process-release.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var semver = require('semver')
22
, url = require('url')
33
, path = require('path')
4+
, log = require('npmlog')
45

56
// versions where -headers.tar.gz started shipping
67
, headersTarballRange = '>= 3.0.0 || ~0.12.10 || ~0.10.42'
@@ -52,10 +53,25 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) {
5253

5354
// check for the nvm.sh standard mirror env variables
5455
if (!overrideDistUrl) {
55-
if (isIojs && process.env.NVM_IOJS_ORG_MIRROR)
56-
overrideDistUrl = process.env.NVM_IOJS_ORG_MIRROR
57-
else if (process.env.NVM_NODEJS_ORG_MIRROR)
58-
overrideDistUrl = process.env.NVM_NODEJS_ORG_MIRROR
56+
if (isIojs) {
57+
if (process.env.IOJS_ORG_MIRROR) {
58+
overrideDistUrl = process.env.IOJS_ORG_MIRROR
59+
} else if (process.env.NVM_IOJS_ORG_MIRROR) {// remove on next semver-major
60+
overrideDistUrl = process.env.NVM_IOJS_ORG_MIRROR
61+
log.warn('download',
62+
'NVM_IOJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, ' +
63+
'please use IOJS_ORG_MIRROR')
64+
}
65+
} else {
66+
if (process.env.NODEJS_ORG_MIRROR) {
67+
overrideDistUrl = process.env.NODEJS_ORG_MIRROR
68+
} else if (process.env.NVM_NODEJS_ORG_MIRROR) {// remove on next semver-major
69+
overrideDistUrl = process.env.NVM_NODEJS_ORG_MIRROR
70+
log.warn('download',
71+
'NVM_NODEJS_ORG_MIRROR is deprecated and will be removed in node-gyp v4, ' +
72+
'please use NODEJS_ORG_MIRROR')
73+
}
74+
}
5975
}
6076

6177

test/docker.sh

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
#set -e
44

5-
test_node_versions="0.8.28 0.10.40 0.12.7"
5+
test_node_versions="0.8.28 0.10.40 0.12.7 4.3.0 5.6.0"
66
test_iojs_versions="1.8.4 2.4.0 3.3.0"
77

8+
myuid=$(id -u)
9+
mygid=$(id -g)
810
__dirname="$(CDPATH= cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
911
dot_node_gyp=${__dirname}/.node-gyp/
1012

@@ -41,6 +43,7 @@ run_tests() {
4143
/bin/su -s /bin/bash node-gyp -c 'cd && ${run_cmd}'"
4244

4345
rm -rf $dot_node_gyp
46+
mkdir $dot_node_gyp
4447

4548
docker run \
4649
--rm -i \
@@ -52,10 +55,10 @@ run_tests() {
5255

5356
# A base image with build tools and a user account
5457
setup_container "node-gyp-test/base" "ubuntu:14.04" "
58+
adduser --gecos node-gyp --home /node-gyp/ --disabled-login node-gyp --uid $myuid &&
59+
echo "node-gyp:node-gyp" | chpasswd &&
5560
apt-get update &&
56-
apt-get install -y build-essential python git rsync curl &&
57-
adduser --gecos node-gyp --home /node-gyp/ --disabled-login node-gyp &&
58-
echo "node-gyp:node-gyp" | chpasswd
61+
apt-get install -y build-essential python git rsync curl
5962
"
6063

6164
# An image on top of the base containing clones of repos we want to use for testing
@@ -111,7 +114,9 @@ test_download_node_version() {
111114
test_download_node_version "0.12.7" "0.10.30/src" "0.10.30"
112115
test_download_node_version "3.3.0" "iojs-1.8.4/src" "1.8.4"
113116
# should download the headers file
114-
test_download_node_version "3.3.0" "iojs-3.2.0/include/node" "3.2.0"
117+
test_download_node_version "3.3.0" "iojs-3.3.0/include/node" "3.3.0"
118+
test_download_node_version "4.3.0" "4.3.0/include/node" "4.3.0"
119+
test_download_node_version "5.6.0" "5.6.0/include/node" "5.6.0"
115120

116121
# TODO: test --dist-url by starting up a localhost server and serving up tarballs
117122

@@ -126,18 +131,34 @@ run_tests "3.3.0" "
126131
nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\"
127132
"
128133

134+
# REMOVE after next semver-major
129135
run_tests "3.3.0" "
130136
(node /node-gyp-src/test/simple-proxy.js 8080 /doobar/ https://iojs.org/dist/ &) &&
131137
cd node-buffertools &&
132138
NVM_IOJS_ORG_MIRROR=http://localhost:8080/doobar/ /node-gyp-src/bin/node-gyp.js --loglevel=info rebuild &&
133139
nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\"
134140
"
135141

142+
# REMOVE after next semver-major
136143
run_tests "0.12.7" "
137144
(node /node-gyp-src/test/simple-proxy.js 8080 /boombar/ https://nodejs.org/dist/ &) &&
138145
cd node-buffertools &&
139146
NVM_NODEJS_ORG_MIRROR=http://localhost:8080/boombar/ /node-gyp-src/bin/node-gyp.js --loglevel=info rebuild &&
140147
nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\"
141148
"
142149

150+
run_tests "3.3.0" "
151+
(node /node-gyp-src/test/simple-proxy.js 8080 /doobar/ https://iojs.org/dist/ &) &&
152+
cd node-buffertools &&
153+
IOJS_ORG_MIRROR=http://localhost:8080/doobar/ /node-gyp-src/bin/node-gyp.js --loglevel=info rebuild &&
154+
nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\"
155+
"
156+
157+
run_tests "0.12.7" "
158+
(node /node-gyp-src/test/simple-proxy.js 8080 /boombar/ https://nodejs.org/dist/ &) &&
159+
cd node-buffertools &&
160+
NODEJS_ORG_MIRROR=http://localhost:8080/boombar/ /node-gyp-src/bin/node-gyp.js --loglevel=info rebuild &&
161+
nc -z localhost 8080 && echo -e \"\\n\\n\\033[31mFAILED TO USE LOCAL PROXY\\033[39m\\n\\n\"
162+
"
163+
143164
rm -rf $dot_node_gyp

test/test-process-release.js

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,3 +519,119 @@ test('test process release - process.release ~ [email protected] - bogus string pa
519519
})
520520
})
521521

522+
test('test process release - NODEJS_ORG_MIRROR', function (t) {
523+
t.plan(2)
524+
525+
process.env.NODEJS_ORG_MIRROR = 'http://foo.bar'
526+
527+
var release = processRelease([], { opts: {} }, 'v4.1.23', {
528+
name: 'node',
529+
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
530+
})
531+
532+
t.equal(release.semver.version, '4.1.23')
533+
delete release.semver
534+
535+
t.deepEqual(release, {
536+
version: '4.1.23',
537+
name: 'node',
538+
baseUrl: 'http://foo.bar/v4.1.23/',
539+
tarballUrl: 'http://foo.bar/v4.1.23/node-v4.1.23-headers.tar.gz',
540+
shasumsUrl: 'http://foo.bar/v4.1.23/SHASUMS256.txt',
541+
versionDir: '4.1.23',
542+
libUrl32: 'http://foo.bar/v4.1.23/win-x86/node.lib',
543+
libUrl64: 'http://foo.bar/v4.1.23/win-x64/node.lib',
544+
libPath32: 'win-x86/node.lib',
545+
libPath64: 'win-x64/node.lib'
546+
})
547+
548+
delete process.env.NODEJS_ORG_MIRROR
549+
})
550+
551+
test('test process release - NVM_NODEJS_ORG_MIRROR', function (t) {
552+
t.plan(2)
553+
554+
process.env.NVM_NODEJS_ORG_MIRROR = 'http://foo.bar'
555+
556+
var release = processRelease([], { opts: {} }, 'v4.1.23', {
557+
name: 'node',
558+
headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz'
559+
})
560+
561+
t.equal(release.semver.version, '4.1.23')
562+
delete release.semver
563+
564+
t.deepEqual(release, {
565+
version: '4.1.23',
566+
name: 'node',
567+
baseUrl: 'http://foo.bar/v4.1.23/',
568+
tarballUrl: 'http://foo.bar/v4.1.23/node-v4.1.23-headers.tar.gz',
569+
shasumsUrl: 'http://foo.bar/v4.1.23/SHASUMS256.txt',
570+
versionDir: '4.1.23',
571+
libUrl32: 'http://foo.bar/v4.1.23/win-x86/node.lib',
572+
libUrl64: 'http://foo.bar/v4.1.23/win-x64/node.lib',
573+
libPath32: 'win-x86/node.lib',
574+
libPath64: 'win-x64/node.lib'
575+
})
576+
577+
delete process.env.NVM_NODEJS_ORG_MIRROR
578+
})
579+
580+
test('test process release - IOJS_ORG_MIRROR', function (t) {
581+
t.plan(2)
582+
583+
process.env.IOJS_ORG_MIRROR = 'http://foo.bar'
584+
585+
var release = processRelease([], { opts: {} }, 'v3.2.24', {
586+
name: 'io.js',
587+
headersUrl: 'http://foo.bar/v3.2.24/iojs-v3.2.24-headers.tar.gz'
588+
})
589+
590+
t.equal(release.semver.version, '3.2.24')
591+
delete release.semver
592+
593+
t.deepEqual(release, {
594+
version: '3.2.24',
595+
name: 'iojs',
596+
baseUrl: 'http://foo.bar/v3.2.24/',
597+
tarballUrl: 'http://foo.bar/v3.2.24/iojs-v3.2.24-headers.tar.gz',
598+
shasumsUrl: 'http://foo.bar/v3.2.24/SHASUMS256.txt',
599+
versionDir: 'iojs-3.2.24',
600+
libUrl32: 'http://foo.bar/v3.2.24/win-x86/iojs.lib',
601+
libUrl64: 'http://foo.bar/v3.2.24/win-x64/iojs.lib',
602+
libPath32: 'win-x86/iojs.lib',
603+
libPath64: 'win-x64/iojs.lib'
604+
})
605+
606+
delete process.env.IOJS_ORG_MIRROR
607+
})
608+
609+
610+
test('test process release - NVM_IOJS_ORG_MIRROR', function (t) {
611+
t.plan(2)
612+
613+
process.env.NVM_IOJS_ORG_MIRROR = 'http://foo.bar'
614+
615+
var release = processRelease([], { opts: {} }, 'v3.2.24', {
616+
name: 'io.js',
617+
headersUrl: 'http://foo.bar/v3.2.24/iojs-v3.2.24-headers.tar.gz'
618+
})
619+
620+
t.equal(release.semver.version, '3.2.24')
621+
delete release.semver
622+
623+
t.deepEqual(release, {
624+
version: '3.2.24',
625+
name: 'iojs',
626+
baseUrl: 'http://foo.bar/v3.2.24/',
627+
tarballUrl: 'http://foo.bar/v3.2.24/iojs-v3.2.24-headers.tar.gz',
628+
shasumsUrl: 'http://foo.bar/v3.2.24/SHASUMS256.txt',
629+
versionDir: 'iojs-3.2.24',
630+
libUrl32: 'http://foo.bar/v3.2.24/win-x86/iojs.lib',
631+
libUrl64: 'http://foo.bar/v3.2.24/win-x64/iojs.lib',
632+
libPath32: 'win-x86/iojs.lib',
633+
libPath64: 'win-x64/iojs.lib'
634+
})
635+
636+
delete process.env.NVM_IOJS_ORG_MIRROR
637+
})

0 commit comments

Comments
 (0)