diff --git a/lib/util/versioning.js b/lib/util/versioning.js index b69b367e..de86282c 100644 --- a/lib/util/versioning.js +++ b/lib/util/versioning.js @@ -313,8 +313,9 @@ module.exports.evaluate = function(package_json, options, napi_build_version) { // support host mirror with npm config `--{module_name}_binary_host_mirror` // e.g.: https://github.com/node-inspector/v8-profiler/blob/master/package.json#L25 // > npm install v8-profiler --profiler_binary_host_mirror=https://registry.npmmirror.com/node-inspector/ - const validModuleName = opts.module_name.replace('-', '_'); - const host = process.env['npm_config_' + validModuleName + '_binary_host_mirror'] || package_json.binary.host; + const validModuleName = opts.module_name.replace(/-/g, '_'); + const envNameSuffix = validModuleName + '_binary_host_mirror'; + const host = process.env['npm_config_' + envNameSuffix] || process.env[envNameSuffix.toUpperCase()] || package_json.binary.host; opts.host = fix_slashes(eval_template(host, opts)); opts.module_path = eval_template(package_json.binary.module_path, opts); // now we resolve the module_path to ensure it is absolute so that binding.gyp variables work predictably diff --git a/test/versioning.test.js b/test/versioning.test.js index 77e3b75f..7544ee58 100644 --- a/test/versioning.test.js +++ b/test/versioning.test.js @@ -181,6 +181,26 @@ test('should detect custom binary host from env', (t) => { t.end(); }); +test('should detect custom binary host from uppercase env', (t) => { + const mock_package_json = { + 'name': 'test', + 'main': 'test.js', + 'version': '0.1.0', + 'binary': { + 'module_name': 'test', + 'module_path': './lib/binding/{configuration}/{toolset}/{name}', + 'remote_path': './{name}/v{version}/{configuration}/{version}/{toolset}/', + 'package_name': '{module_name}-v{major}.{minor}.{patch}-{prerelease}+{build}-{toolset}-{node_abi}-{platform}-{arch}.tar.gz', + 'host': 'https://some-bucket.s3.us-east-1.amazonaws.com' + } + }; + process.env.TEST_BINARY_HOST_MIRROR = 'https://registry.npmmirror.com/node-inspector/'; + const opts = versioning.evaluate(mock_package_json, {}); + t.equal(opts.host, 'https://registry.npmmirror.com/node-inspector/'); + delete process.env.TEST_BINARY_HOST_MIRROR; + t.end(); +}); + test('should detect libc', (t) => { const mock_package_json = { 'name': 'test',