diff --git a/e2e/nx-run/src/invoke-runner.test.ts b/e2e/nx-run/src/invoke-runner.test.ts index e774eaa787f7d..5d9faa7b048d5 100644 --- a/e2e/nx-run/src/invoke-runner.test.ts +++ b/e2e/nx-run/src/invoke-runner.test.ts @@ -46,8 +46,8 @@ describe('Invoke Runner', () => { async function main(){ const r = await initTasksRunner({}); - await r.invoke([{id: '${mylib}:prebuild', target: {project: '${mylib}', target: 'prebuild'}, overrides: {__overrides_unparsed__: ''}}]); - await r.invoke([{id: '${mylib}:build', target: {project: '${mylib}', target: 'build'}, overrides: {__overrides_unparsed__: ''}}]); + await r.invoke({tasks: [{id: '${mylib}:prebuild', target: {project: '${mylib}', target: 'prebuild'}, overrides: {__overrides_unparsed__: ''}}]}); + await r.invoke({tasks: [{id: '${mylib}:build', target: {project: '${mylib}', target: 'build'}, overrides: {__overrides_unparsed__: ''}}]}); } main().then(q => { diff --git a/packages/nx/src/tasks-runner/init-tasks-runner.ts b/packages/nx/src/tasks-runner/init-tasks-runner.ts index 3d3e47a77fab0..7dd1a0ba30e4e 100644 --- a/packages/nx/src/tasks-runner/init-tasks-runner.ts +++ b/packages/nx/src/tasks-runner/init-tasks-runner.ts @@ -16,31 +16,32 @@ export async function initTasksRunner(nxArgs: NxArgs) { } const projectGraph = await createProjectGraphAsync({ exitOnError: true }); return { - invoke: async ( - tasks: Task[] - ): Promise<{ status: number; taskGraph: TaskGraph }> => { + invoke: async (opts: { + tasks: Task[]; + parallel: number; + }): Promise<{ status: number; taskGraph: TaskGraph }> => { performance.mark('command-execution-begins'); const lifeCycle = new InvokeRunnerTerminalOutputLifeCycle(tasks); const taskGraph = { - roots: tasks.map((task) => task.id), - tasks: tasks.reduce((acc, task) => { + roots: opts.tasks.map((task) => task.id), + tasks: opts.tasks.reduce((acc, task) => { acc[task.id] = task; return acc; }, {} as any), - dependencies: tasks.reduce((acc, task) => { + dependencies: opts.tasks.reduce((acc, task) => { acc[task.id] = []; return acc; }, {} as any), }; const status = await invokeTasksRunner({ - tasks, + tasks: opts.tasks, projectGraph, taskGraph, lifeCycle, nxJson, - nxArgs, + nxArgs: { ...nxArgs, parallel: opts.parallel }, loadDotEnvFiles: true, initiatingProject: null, }); diff --git a/packages/nx/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.ts b/packages/nx/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.ts index 1a7a601fa5b75..69d57aa9f511e 100644 --- a/packages/nx/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.ts +++ b/packages/nx/src/tasks-runner/life-cycles/invoke-runner-terminal-output-life-cycle.ts @@ -18,8 +18,8 @@ export class InvokeRunnerTerminalOutputLifeCycle implements LifeCycle { bodyLines: this.tasks.map( (task) => `- Task ${task.id} ${ - task.overrides.__overrides_unparsed__ - ? `Overrides: ${task.overrides.__overrides_unparsed__}` + task.overrides.__overrides_unparsed__.length > 0 + ? `Overrides: ${task.overrides.__overrides_unparsed__.join(' ')}` : '' }` ), @@ -34,8 +34,8 @@ export class InvokeRunnerTerminalOutputLifeCycle implements LifeCycle { const cached = this.cachedTasks.indexOf(task) !== -1; const failed = this.failedTasks.indexOf(task) !== -1; return `- Task ${task.id} ${ - task.overrides.__overrides_unparsed__ - ? `Overrides: ${task.overrides.__overrides_unparsed__}` + task.overrides.__overrides_unparsed__.length > 0 + ? `Overrides: ${task.overrides.__overrides_unparsed__.join(' ')}` : '' } ${cached ? 'CACHED' : ''} ${failed ? 'FAILED' : ''}`; });