Skip to content

Commit

Permalink
feat: optimize runs with projects list by grouping the runs by the ta…
Browse files Browse the repository at this point in the history
…rget
  • Loading branch information
jeremylvln committed Jan 30, 2023
1 parent 350f690 commit ece3ed8
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/run-nx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,18 @@ async function runNxProjects(
inputs: Inputs,
args: readonly string[],
): Promise<void> {
return inputs.projects
.flatMap((project) =>
inputs.targets.map((target): [string, string] => [project, target]),
)
.reduce(
(lastPromise, [project, target]) =>
lastPromise.then(() => nx([target, project, ...args])),
Promise.resolve(),
);
return inputs.targets.reduce(
(lastPromise, target) =>
lastPromise.then(() =>
nx([
'run-many',
`--target=${target}`,
`--projects=${inputs.projects.join(',')}`,
...args,
]),
),
Promise.resolve(),
);
}

async function runNxAffected(
Expand Down

0 comments on commit ece3ed8

Please sign in to comment.