From 55a701c05fffa353a731f063303c03a5ce8bee70 Mon Sep 17 00:00:00 2001 From: Jason Jean Date: Thu, 22 Jun 2023 11:35:20 -0400 Subject: [PATCH] fix(core): fix batch mode not streaming outputs (#17717) --- packages/nx/src/tasks-runner/run-command.ts | 24 ++++++++++++--------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/packages/nx/src/tasks-runner/run-command.ts b/packages/nx/src/tasks-runner/run-command.ts index 7f348d84f0dba3..809609ddc51554 100644 --- a/packages/nx/src/tasks-runner/run-command.ts +++ b/packages/nx/src/tasks-runner/run-command.ts @@ -46,10 +46,11 @@ async function getTerminalOutputLifeCycle( ): Promise<{ lifeCycle: LifeCycle; renderIsDone: Promise }> { const { runnerOptions } = getRunner(nxArgs, nxJson); const isRunOne = initiatingProject != null; - const useDynamicOutput = - shouldUseDynamicLifeCycle(tasks, runnerOptions, nxArgs.outputStyle) && - process.env.NX_VERBOSE_LOGGING !== 'true' && - process.env.NX_TASKS_RUNNER_DYNAMIC_OUTPUT !== 'false'; + const useDynamicOutput = shouldUseDynamicLifeCycle( + tasks, + runnerOptions, + nxArgs.outputStyle + ); const overridesWithoutHidden = { ...overrides }; delete overridesWithoutHidden['__overrides_unparsed__']; @@ -195,10 +196,7 @@ export async function runCommand( } function setEnvVarsBasedOnArgs(nxArgs: NxArgs, loadDotEnvFiles: boolean) { - if (process.env.NX_BATCH_MODE === 'true') { - nxArgs.outputStyle = 'stream'; - } - if (nxArgs.outputStyle == 'stream') { + if (nxArgs.outputStyle == 'stream' || process.env.NX_BATCH_MODE === 'true') { process.env.NX_STREAM_OUTPUT = 'true'; process.env.NX_PREFIX_OUTPUT = 'true'; } @@ -360,12 +358,18 @@ function shouldUseDynamicLifeCycle( options: any, outputStyle: string ) { + if ( + process.env.NX_BATCH_MODE === 'true' || + process.env.NX_VERBOSE_LOGGING === 'true' || + process.env.NX_TASKS_RUNNER_DYNAMIC_OUTPUT === 'false' + ) { + return false; + } if (!process.stdout.isTTY) return false; if (isCI()) return false; if (outputStyle === 'static' || outputStyle === 'stream') return false; - const noForwarding = !tasks.find((t) => shouldStreamOutput(t, null, options)); - return noForwarding; + return !tasks.find((t) => shouldStreamOutput(t, null, options)); } export function getRunner(