Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,6 @@ const cli = configureProject(
'@types/fs-extra@^11',
'@types/mockery',
'@types/picomatch',
'@types/promptly',
'@types/semver',
'@types/sinon',
'@types/yargs@^15',
Expand Down Expand Up @@ -1243,13 +1242,12 @@ const cli = configureProject(
'chalk@^4',
'chokidar@^4',
'decamelize@^5', // Non-ESM
'enquirer',
'@clack/core',
'fs-extra@^11',
'fast-glob',
'picomatch',
'p-limit@^3',
'p-queue@^6',
'promptly',
'proxy-agent',
'semver',
'strip-ansi@^6',
Expand Down Expand Up @@ -1286,6 +1284,11 @@ const cli = configureProject(
},
jestOptions: jestOptionsForProject({
jestConfig: {
// @clack/core is ESM-only and cannot be loaded by Jest in CJS mode.
// Map it to a manual mock that provides safe defaults for all tests.
moduleNameMapper: {
'^@clack/core$': '<rootDir>/test/_helpers/mock-clack-core.js',
},
coverageThreshold: {
// We want to improve our test coverage
// DO NOT LOWER THESE VALUES!
Expand Down
12 changes: 9 additions & 3 deletions packages/@aws-cdk-testing/cli-integ/lib/shell.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type * as child_process from 'child_process';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import type { TestContext } from './integ-test';
import { Process } from './process';
Expand Down Expand Up @@ -69,7 +68,10 @@ export async function shell(command: string[], options: ShellOptions = {}): Prom
// now write the input with a slight delay to ensure
// the child process has already started reading.
const sendInput = () => {
child.writeStdin(interaction.input + (interaction.end ?? os.EOL));
// Use \r (carriage return) as default line ending — this is what real terminals
// send when Enter is pressed. Some prompt libraries (e.g. @clack/core) only
// recognize \r as the submit key, not \n.
child.writeStdin(interaction.input + (interaction.end ?? '\r'));
};

if (interaction.beforeInput) {
Expand Down Expand Up @@ -340,7 +342,11 @@ class LastLine {
private lastLine: string = '';

public append(chunk: string): void {
const lines = chunk.split(os.EOL);
// Strip ANSI escape codes so prompt matching works regardless of terminal styling
const clean = chunk.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, '');
// Split on \r, \n, or \r\n — interactive prompt libraries like @clack/prompts
// use \r and cursor movement instead of plain \n for re-rendering
const lines = clean.split(/\r?\n|\r/);
if (lines.length === 1) {
// chunk doesn't contain a new line so just append
this.lastLine += lines[0];
Expand Down
16 changes: 4 additions & 12 deletions packages/aws-cdk/.projen/deps.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/aws-cdk/.projen/tasks.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading