Skip to content

Commit

Permalink
chore: update run-affected with multiple targets api supported in nx …
Browse files Browse the repository at this point in the history
…15.4
  • Loading branch information
Hotell committed Feb 22, 2023
1 parent cd57b33 commit 08954ed
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions scripts/executors/run-affected.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { execSync } from 'child_process';
import { cpus } from 'os';
import { promisify } from 'util';

import { getAffectedPackages } from '@fluentui/scripts-monorepo';
Expand All @@ -12,21 +13,21 @@ main().catch(err => {
});

async function main() {
const cpusCount = cpus().length;
const args = processArgs();
const targetCount = args.target.length;

const affectedPackages = Array.from(getAffectedPackages(args.base)).filter(projectName => {
return ['@fluentui/noop'].indexOf(projectName) === -1;
});

const taskResults = args.target.map(target => {
const cmd = `nx run-many --parallel=8 --target=${target} --projects=${affectedPackages}`;
console.log(`running: ${cmd}`);
// @ts-expect-error - bad promisify type inference
return exec(cmd, { stdio: 'inherit' });
});
const cmd = `nx run-many --parallel=${cpusCount} --target${targetCount > 1 ? 's' : ''}=${
args.target
} --projects=${affectedPackages}`;

try {
const result = await Promise.all(taskResults);
// @ts-expect-error - bad promisify type inference
const result = await exec(cmd, { stdio: 'inherit' });
console.log(result);
console.log('✅ all tasks done');
process.exit(0);
Expand Down

0 comments on commit 08954ed

Please sign in to comment.