Skip to content

Commit e516eca

Browse files
merge master
2 parents a4fe8bf + 13202cb commit e516eca

File tree

3 files changed

+24
-3
lines changed

3 files changed

+24
-3
lines changed

src/cli/commands.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ export default {
133133
boolean: true,
134134
description: 'Skip packaging step',
135135
default: false
136+
},
137+
registries: {
138+
array: true,
139+
description:
140+
'List of registries to publish to. This setting will take precedence over oc.json file'
136141
}
137142
},
138143
description: 'Publish a component',

src/cli/facade/publish.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const publish = ({
2828
skipPackage?: boolean;
2929
username?: string;
3030
password?: string;
31+
registries?: string[];
3132
}): Promise<void> => {
3233
const componentPath = opts.componentPath;
3334
const skipPackage = opts.skipPackage;
@@ -160,7 +161,7 @@ const publish = ({
160161
};
161162

162163
try {
163-
const registryLocations = await registry.get();
164+
const registryLocations = opts.registries || (await registry.get());
164165

165166
if (!skipPackage) {
166167
await handleDependencies({

test/unit/cli-facade-publish.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('cli : facade : publish', () => {
2020

2121
const execute = function (
2222
cb,
23-
{ creds = {}, skipPackage = false, fs = {} } = {}
23+
{ creds = {}, skipPackage = false, fs = {}, registries } = {}
2424
) {
2525
logSpy.err = sinon.stub();
2626
logSpy.log = sinon.stub();
@@ -47,7 +47,8 @@ describe('cli : facade : publish', () => {
4747
componentPath: 'test/fixtures/components/hello-world/',
4848
username: creds.username,
4949
password: creds.password,
50-
skipPackage
50+
skipPackage,
51+
registries
5152
},
5253
() => {
5354
cb();
@@ -101,6 +102,20 @@ describe('cli : facade : publish', () => {
101102
});
102103
});
103104

105+
it('should take precedence over the registries set through oc.json', done => {
106+
sinon.stub(registry, 'putComponent').resolves('ok');
107+
execute(
108+
() => {
109+
registry.putComponent.restore();
110+
111+
expect(logSpy.ok.args[0][0]).to.include('http://www.newapi.com');
112+
expect(logSpy.ok.args[1][0]).to.include('http://www.newapi2.com');
113+
done();
114+
},
115+
{ registries: ['http://www.newapi.com', 'http://www.newapi2.com'] }
116+
);
117+
});
118+
104119
describe('when packaging', () => {
105120
describe('when a component is not valid', () => {
106121
beforeEach(done => {

0 commit comments

Comments
 (0)