From 0e38be7c234e9519a8281a9fb384afd3b148cc4c Mon Sep 17 00:00:00 2001 From: xiaoxiaojx <784487301@qq.com> Date: Thu, 14 Jul 2022 19:40:09 +0800 Subject: [PATCH 1/2] feat: support for configuring nodejs_org_mirror in .npmrc --- lib/process-release.js | 5 +++-- test/test-process-release.js | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/lib/process-release.js b/lib/process-release.js index 95b55e4426..391282dec9 100644 --- a/lib/process-release.js +++ b/lib/process-release.js @@ -20,6 +20,7 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { var version = (semver.valid(argv[0]) && argv[0]) || gyp.opts.target || defaultVersion var versionSemver = semver.parse(version) var overrideDistUrl = gyp.opts['dist-url'] || gyp.opts.disturl + var npmConfigUrlOrEnvUrl = process.env.NODEJS_ORG_MIRROR || process.env.npm_config_nodejs_org_mirror var isDefaultVersion var isNamedForLegacyIojs var name @@ -62,8 +63,8 @@ function processRelease (argv, gyp, defaultVersion, defaultRelease) { } // check for the nvm.sh standard mirror env variables - if (!overrideDistUrl && process.env.NODEJS_ORG_MIRROR) { - overrideDistUrl = process.env.NODEJS_ORG_MIRROR + if (!overrideDistUrl && npmConfigUrlOrEnvUrl) { + overrideDistUrl = npmConfigUrlOrEnvUrl } if (overrideDistUrl) { diff --git a/test/test-process-release.js b/test/test-process-release.js index c3ee0703c5..f27a1fe648 100644 --- a/test/test-process-release.js +++ b/test/test-process-release.js @@ -432,3 +432,32 @@ test('test process release - NODEJS_ORG_MIRROR', function (t) { delete process.env.NODEJS_ORG_MIRROR }) + +test('test process release - npm_config_nodejs_org_mirror', function (t) { + t.plan(2) + + // is equivalent to setting nodejs_org_mirror=http://foo.bar in the .npmrc file + process.env.npm_config_nodejs_org_mirror = 'http://foo.bar' + + var release = processRelease([], { opts: {} }, 'v4.1.23', { + name: 'node', + headersUrl: 'https://nodejs.org/dist/v4.1.23/node-v4.1.23-headers.tar.gz' + }) + + t.equal(release.semver.version, '4.1.23') + delete release.semver + + t.deepEqual(release, { + version: '4.1.23', + name: 'node', + baseUrl: 'http://foo.bar/v4.1.23/', + tarballUrl: 'http://foo.bar/v4.1.23/node-v4.1.23-headers.tar.gz', + shasumsUrl: 'http://foo.bar/v4.1.23/SHASUMS256.txt', + versionDir: '4.1.23', + ia32: { libUrl: 'http://foo.bar/v4.1.23/win-x86/node.lib', libPath: 'win-x86/node.lib' }, + x64: { libUrl: 'http://foo.bar/v4.1.23/win-x64/node.lib', libPath: 'win-x64/node.lib' }, + arm64: { libUrl: 'http://foo.bar/v4.1.23/win-arm64/node.lib', libPath: 'win-arm64/node.lib' } + }) + + delete process.env.npm_config_nodejs_org_mirror +}) \ No newline at end of file From 4e23c0836aff2090f3f8a80c480b6a06dd74ce64 Mon Sep 17 00:00:00 2001 From: xiaoxiaojx <784487301@qq.com> Date: Thu, 14 Jul 2022 20:05:13 +0800 Subject: [PATCH 2/2] fix: lint --- test/test-process-release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test-process-release.js b/test/test-process-release.js index f27a1fe648..b1e3371b4f 100644 --- a/test/test-process-release.js +++ b/test/test-process-release.js @@ -460,4 +460,4 @@ test('test process release - npm_config_nodejs_org_mirror', function (t) { }) delete process.env.npm_config_nodejs_org_mirror -}) \ No newline at end of file +})