diff --git a/lib/subprocess.js b/lib/subprocess.js index 872f3cc..a266e10 100644 --- a/lib/subprocess.js +++ b/lib/subprocess.js @@ -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); + } }); };