Skip to content

Commit

Permalink
fix: use readline for iterator
Browse files Browse the repository at this point in the history
Instead of hoping each chunk is a single line of output, this uses the
readline module to read the stream line by line.
  • Loading branch information
43081j committed Jun 15, 2024
1 parent 7809a84 commit efb657f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {normalize as normalizePath} from 'node:path';
import {cwd as getCwd} from 'node:process';
import {computeEnv} from './env.js';
import {readStreamAsString, combineStreams} from './stream.js';
import readline from 'node:readline';

export interface Output {
stderr: string;
Expand Down Expand Up @@ -146,8 +147,11 @@ export class ExecProcess implements Result {
sources.push(proc.stdout);
}
const combined = combineStreams(sources);
const rl = readline.createInterface({
input: combined
});

for await (const chunk of combined) {
for await (const chunk of rl) {
yield chunk.toString();
}

Expand Down

0 comments on commit efb657f

Please sign in to comment.