Skip to content

Commit 3e68090

Browse files
committed
feat: print msg
1 parent bcf8533 commit 3e68090

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/aws-cdk/lib/cli/io-host/cli-io-host.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,19 @@ export class CliIoHost implements IIoHost {
438438
if (this.autoRespond) {
439439
// respond with yes to all confirmations
440440
if (isConfirmationPrompt(msg)) {
441-
// @TODO print message and confirmation
441+
await this.notify({
442+
...msg,
443+
message: `${chalk.cyan(msg.message)} (auto-confirmed)`,
444+
});
442445
return true;
443446
}
444447

445448
// respond with the default for all other messages
446449
if (msg.defaultResponse) {
447-
// @TODO print message and response
450+
await this.notify({
451+
...msg,
452+
message: `${chalk.cyan(msg.message)} (auto-responded with default: ${util.format(msg.defaultResponse)})`,
453+
});
448454
return msg.defaultResponse;
449455
}
450456
}

packages/aws-cdk/test/cli/io-host/cli-io-host.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,8 @@ describe('CliIoHost', () => {
503503
}, true);
504504

505505
test('it does not prompt the user and return true', async () => {
506+
const notifySpy = jest.spyOn(autoRespondingIoHost, 'notify');
507+
506508
// WHEN
507509
const response = await autoRespondingIoHost.requestResponse(plainMessage({
508510
time: new Date(),
@@ -515,10 +517,15 @@ describe('CliIoHost', () => {
515517

516518
// THEN
517519
expect(mockStdout).not.toHaveBeenCalledWith(chalk.cyan('test message') + ' (y/n) ');
520+
expect(notifySpy).toHaveBeenCalledWith(expect.objectContaining({
521+
message: chalk.cyan('test message') + ' (auto-confirmed)',
522+
}));
518523
expect(response).toBe(true);
519524
});
520525

521526
test('messages with default are skipped', async () => {
527+
const notifySpy = jest.spyOn(autoRespondingIoHost, 'notify');
528+
522529
// WHEN
523530
const response = await autoRespondingIoHost.requestResponse(plainMessage({
524531
time: new Date(),
@@ -531,6 +538,9 @@ describe('CliIoHost', () => {
531538

532539
// THEN
533540
expect(mockStdout).not.toHaveBeenCalledWith(chalk.cyan('test message') + ' (y/n) ');
541+
expect(notifySpy).toHaveBeenCalledWith(expect.objectContaining({
542+
message: chalk.cyan('test message') + ' (auto-responded with default: foobar)',
543+
}));
534544
expect(response).toBe('foobar');
535545
});
536546
});

0 commit comments

Comments
 (0)