Skip to content

Commit

Permalink
publish command ignores --public flag since product events are never …
Browse files Browse the repository at this point in the history
…public
  • Loading branch information
busticated committed Apr 14, 2020
1 parent 0471fe4 commit d522d53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/cmd/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ module.exports = class PublishCommand {
}

publishEvent({ private: isPrivate, public: isPublic, product, params: { event, data } }){
const setPrivate = isPublic ? false : isPrivate;
const visibility = setPrivate ? 'private' : 'public';
isPrivate = (isPublic && !product) ? false : isPrivate; // `isPrivate: true` by default see: src/cli/publish.js
const visibility = isPrivate ? 'private' : 'public';
let epilogue = `${visibility} event: ${event}`;

if (product){
epilogue += ` to product: ${product}`;
}

const publishEvent = createAPI().publishEvent(event, data, setPrivate, product);
const publishEvent = createAPI().publishEvent(event, data, isPrivate, product);
return this.showBusySpinnerUntilResolved(`Publishing ${epilogue}`, publishEvent)
.then(() => this.ui.stdout.write(`Published ${epilogue}${os.EOL}${os.EOL}`))
.catch(error => {
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/publish.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ describe('Publish Commands', () => {
expect(exitCode).to.equal(0);
});

it('Publishes a public product event', async () => {
it('Ignores `--public` flag when publishing a product event', async () => {
const args = ['publish', eventName, '--product', PRODUCT_01_ID, '--public'];
const { stdout, stderr, exitCode } = await cli.run(args);

expect(stdout).to.include(`Published public event: ${eventName} to product: ${PRODUCT_01_ID}${os.EOL}`);
expect(stdout).to.include(`Published private event: ${eventName} to product: ${PRODUCT_01_ID}${os.EOL}`);
expect(stderr).to.equal('');
expect(exitCode).to.equal(0);
});
Expand Down

0 comments on commit d522d53

Please sign in to comment.