From f2dfe90f3ce2e6506e78ed2256af1ed6bba7093e Mon Sep 17 00:00:00 2001 From: Emily Xiong Date: Thu, 26 Sep 2024 10:21:27 -0400 Subject: [PATCH] fix(core): fix output for 0 task (#28122) ## Current Behavior ## Expected Behavior ## Related Issue(s) Fixes # --- .../dynamic-run-many-terminal-output-life-cycle.ts | 5 +++++ .../static-run-many-terminal-output-life-cycle.ts | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/packages/nx/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.ts b/packages/nx/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.ts index 0842002f63d18..0202e3da5fad7 100644 --- a/packages/nx/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.ts +++ b/packages/nx/src/tasks-runner/life-cycles/dynamic-run-many-terminal-output-life-cycle.ts @@ -325,6 +325,11 @@ export async function createRunManyDynamicOutputRenderer({ const timeTakenText = prettyTime(process.hrtime(start)); moveCursorToStartOfPinnedFooter(); + if (totalTasks === 0) { + renderPinnedFooter([output.applyNxPrefix('gray', 'No tasks were run')]); + resolveRenderIsDonePromise(); + return; + } if (totalSuccessfulTasks === totalTasks) { const text = `Successfully ran ${formatTargetsAndProjects( projectNames, diff --git a/packages/nx/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.ts b/packages/nx/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.ts index 3122157d9c5cc..7ca63d0068ff6 100644 --- a/packages/nx/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.ts +++ b/packages/nx/src/tasks-runner/life-cycles/static-run-many-terminal-output-life-cycle.ts @@ -29,6 +29,9 @@ export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle { ) {} startCommand(): void { + if (this.tasks.length === 0) { + return; + } if (this.projectNames.length <= 0) { output.logSingleLine( `No projects with ${formatTargetsAndProjects( @@ -69,6 +72,10 @@ export class StaticRunManyTerminalOutputLifeCycle implements LifeCycle { endCommand(): void { output.addNewline(); + if (this.tasks.length === 0) { + output.logSingleLine(`No tasks were run`); + return; + } if (this.failedTasks.length === 0) { output.addVerticalSeparatorWithoutNewLines('green');