Skip to content

Commit

Permalink
fix: should support contains querystring registry (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored May 21, 2018
1 parent 3703c7e commit 19d1545
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ function* getRemotePackage(name, registry, globalOptions) {
let lastErr;
let pkg;
for (const registry of registries) {
const binaryMirrorUrl = registry + '/' + name + '/latest';
const binaryMirrorUrl = exports.formatPackageUrl(registry, name + '/latest');
try {
const res = yield get(binaryMirrorUrl, {
dataType: 'json',
Expand Down
37 changes: 37 additions & 0 deletions test/custom-registry.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict';

const assert = require('assert');
const path = require('path');
const rimraf = require('rimraf');
const mkdirp = require('mkdirp');
const fs = require('fs');
const coffee = require('coffee');

const npminstall = path.join(__dirname, '..', 'bin', 'install.js');

describe('test/custom-registry.test.js', () => {
const tmp = path.join(__dirname, 'fixtures', 'install-pedding');

function cleanup() {
rimraf.sync(path.join(tmp, 'node_modules'));
}

beforeEach(() => {
cleanup();
mkdirp.sync(tmp);
});
afterEach(cleanup);

it('should install with custom registry', function* () {
const args = [
'--registry=https://r.cnpmjs.org?bucket=foo',
'-d',
];
yield coffee.fork(npminstall, args, { cwd: tmp })
.debug()
.expect('stdout', /All packages installed/)
.expect('code', 0)
.end();
assert(JSON.parse(fs.readFileSync(path.join(tmp, 'node_modules/pedding/package.json'))).version === '0.0.1');
});
});

0 comments on commit 19d1545

Please sign in to comment.