Skip to content
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/util/versioning.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment thread
yunnysunny marked this conversation as resolved.
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
Expand Down
20 changes: 20 additions & 0 deletions test/versioning.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Comment thread
yunnysunny marked this conversation as resolved.
t.end();
});

test('should detect libc', (t) => {
const mock_package_json = {
'name': 'test',
Expand Down