Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support for configuring nodejs_org_mirror in .npmrc #2704

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
29 changes: 29 additions & 0 deletions test/test-process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})