Skip to content

Commit 9711723

Browse files
fix(integration): honour the stdout/stderr write callback in the command runner
The capture function replacing process.stdout.write and process.stderr.write took only the chunk, so a caller using write(chunk, cb) or write(chunk, encoding, cb) never had its callback invoked. Anything waiting on that callback would stall for the duration of the command under test. Addresses Copilot review on PR #235. Co-Authored-By: Harshi Shah <harshi.shah@contentstack.com>
1 parent 01b4dde commit 9711723

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎test/integration/harness/run-command.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ export async function runCommand(
3232
argv: string[],
3333
): Promise<CommandResult> {
3434
const chunks: string[] = [];
35-
const capture = (chunk: any): boolean => {
35+
const capture = (chunk: any, encoding?: any, callback?: any): boolean => {
3636
chunks.push(typeof chunk === 'string' ? chunk : Buffer.from(chunk).toString('utf8'));
37+
const done = typeof encoding === 'function' ? encoding : callback;
38+
if (typeof done === 'function') done();
3739
return true;
3840
};
3941

0 commit comments

Comments
 (0)