Skip to content

Commit

Permalink
fix(cli): skip bundling for the 'watch' command (aws#17455)
Browse files Browse the repository at this point in the history
Add `watch` to the list of commands that require bundling.

Closes aws#17391


----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
jogold authored and TikiTDO committed Feb 21, 2022
1 parent 7f5c1d4 commit e6fe08d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/aws-cdk/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ export enum Command {
METADATA = 'metadata',
INIT = 'init',
VERSION = 'version',
WATCH = 'watch',
}

const BUNDLING_COMMANDS = [
Command.DEPLOY,
Command.DIFF,
Command.SYNTH,
Command.SYNTHESIZE,
Command.WATCH,
];

export type Arguments = {
Expand Down Expand Up @@ -251,7 +253,7 @@ export class Settings {
// Determine bundling stacks
let bundlingStacks: string[];
if (BUNDLING_COMMANDS.includes(argv._[0])) {
// If we deploy, diff or synth a list of stacks exclusively we skip
// If we deploy, diff, synth or watch a list of stacks exclusively we skip
// bundling for all other stacks.
bundlingStacks = argv.exclusively
? argv.STACKS ?? ['*']
Expand Down
22 changes: 22 additions & 0 deletions packages/aws-cdk/test/settings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,16 @@ test('bundling stacks defaults to * for deploy', () => {
expect(settings.get(['bundlingStacks'])).toEqual(['*']);
});

test('bundling stacks defaults to * for watch', () => {
// GIVEN
const settings = Settings.fromCommandLineArguments({
_: [Command.WATCH],
});

// THEN
expect(settings.get(['bundlingStacks'])).toEqual(['*']);
});

test('bundling stacks with deploy exclusively', () => {
// GIVEN
const settings = Settings.fromCommandLineArguments({
Expand All @@ -112,6 +122,18 @@ test('bundling stacks with deploy exclusively', () => {
expect(settings.get(['bundlingStacks'])).toEqual(['cool-stack']);
});

test('bundling stacks with watch exclusively', () => {
// GIVEN
const settings = Settings.fromCommandLineArguments({
_: [Command.WATCH],
exclusively: true,
STACKS: ['cool-stack'],
});

// THEN
expect(settings.get(['bundlingStacks'])).toEqual(['cool-stack']);
});

test('should include outputs-file in settings', () => {
// GIVEN
const settings = Settings.fromCommandLineArguments({
Expand Down

0 comments on commit e6fe08d

Please sign in to comment.