Skip to content

Commit

Permalink
fix(cli): listing same stack multiple times fails (#10554)
Browse files Browse the repository at this point in the history
Fixes listing same stack multiple times fails for cdk commands

closes #9667

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
ayush987goyal authored Sep 30, 2020
1 parent 0d4d44f commit 44c1f20
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/aws-cdk/lib/api/cxapp/cloud-assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export class CloudAssembly {

public async selectStacks(selectors: string[], options: SelectStacksOptions): Promise<StackCollection> {
selectors = selectors.filter(s => s != null); // filter null/undefined
selectors = [...new Set(selectors)]; // make them unique

const stacks = this.assembly.stacks;
if (stacks.length === 0) {
Expand Down
13 changes: 13 additions & 0 deletions packages/aws-cdk/test/api/cloud-assembly.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ test('select behavior: single', async () => {
.rejects.toThrow('Since this app includes more than a single stack, specify which stacks to use (wildcards are supported)');
});

test('select behavior: repeat', async () => {
// GIVEN
const cxasm = await testCloudAssembly();

// WHEN
const x = await cxasm.selectStacks(['withouterrors', 'withouterrors'], {
defaultBehavior: DefaultSelection.AllStacks,
});

// THEN
expect(x.stackCount).toBe(1);
});

async function testCloudAssembly({ env }: { env?: string, versionReporting?: boolean } = {}) {
const cloudExec = new MockCloudExecutable({
stacks: [{
Expand Down

0 comments on commit 44c1f20

Please sign in to comment.