Skip to content

Commit

Permalink
feat: Add line-streamName event to Subprocess (#439)
Browse files Browse the repository at this point in the history
  • Loading branch information
mykola-mokhnach authored Jul 2, 2024
1 parent 6689289 commit f6babc7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/subprocess.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,15 @@ class SubProcess extends EventEmitter {
const handleStreamLines = (/** @type {string} */ streamName, /** @type {import('stream').Readable} */ input) => {
const rl = createInterface({input});
rl.on('line', (line) => {
this.emit(`lines-${streamName}`, [line]);
this.emitLines(streamName, line);
// This event is a legacy one
// It always produces a single-item array
if (this.listenerCount(`lines-${streamName}`)) {
this.emit(`lines-${streamName}`, [line]);
}
this.emit(`line-${streamName}`, line);
if (this.listenerCount('stream-line')) {
this.emitLines(streamName, line);
}
});
};

Expand Down

0 comments on commit f6babc7

Please sign in to comment.