@@ -47,13 +47,21 @@ const pushBuildCommandOutput = function (output: string, logsArray: string[]) {
4747 logsArray . push ( output )
4848}
4949
50+ const pipedPluginProcesses = new WeakMap < ChildProcess , ReturnType < typeof pipePluginOutput > > ( )
51+
5052// Start plugin step output
5153export const pipePluginOutput = function ( childProcess : ChildProcess , logs : Logs , standardStreams : StandardStreams ) {
52- if ( ! logsAreBuffered ( logs ) ) {
53- return streamOutput ( childProcess , standardStreams )
54+ if ( pipedPluginProcesses . has ( childProcess ) ) {
55+ return pipedPluginProcesses . get ( childProcess )
5456 }
5557
56- return pushOutputToLogs ( childProcess , logs , standardStreams . outputFlusher )
58+ const listeners = ! logsAreBuffered ( logs )
59+ ? streamOutput ( childProcess , standardStreams )
60+ : pushOutputToLogs ( childProcess , logs , standardStreams . outputFlusher )
61+
62+ pipedPluginProcesses . set ( childProcess , listeners )
63+
64+ return listeners
5765}
5866
5967// Stop streaming/buffering plugin step output
@@ -71,6 +79,8 @@ export const unpipePluginOutput = async function (
7179 }
7280
7381 unpushOutputToLogs ( childProcess , listeners . stdoutListener , listeners . stderrListener )
82+
83+ pipedPluginProcesses . delete ( childProcess )
7484}
7585
7686// Usually, we stream stdout/stderr because it is more efficient
0 commit comments