Skip to content

Commit 455043e

Browse files
committed
fix(plugin-js-packages): avoid parallel process execution (concurrent spinners not supported)
1 parent 62a48b0 commit 455043e

File tree

1 file changed

+14
-28
lines changed
  • packages/plugin-js-packages/src/lib/runner

1 file changed

+14
-28
lines changed

packages/plugin-js-packages/src/lib/runner/index.ts

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@ import { writeFile } from 'node:fs/promises';
22
import path from 'node:path';
33
import type { RunnerConfig, RunnerFilesPaths } from '@code-pushup/models';
44
import {
5+
asyncSequential,
56
createRunnerFiles,
67
ensureDirectoryExists,
78
executeProcess,
89
filePathToCliArg,
9-
isPromiseFulfilledResult,
10-
isPromiseRejectedResult,
1110
objectFromEntries,
1211
objectToCliArgs,
1312
readJsonFile,
@@ -116,34 +115,21 @@ async function processAudit(
116115
supportedAuditDepGroups.includes(group),
117116
);
118117

119-
const auditResults = await Promise.allSettled(
120-
compatibleAuditDepGroups.map(
121-
async (depGroup): Promise<[DependencyGroup, AuditResult]> => {
122-
const { stdout } = await executeProcess({
123-
command: pm.command,
124-
args: pm.audit.getCommandArgs(depGroup),
125-
cwd: packageJsonPath ? path.dirname(packageJsonPath) : process.cwd(),
126-
ignoreExitCode: pm.audit.ignoreExitCode,
127-
});
128-
return [depGroup, pm.audit.unifyResult(stdout)];
129-
},
130-
),
131-
);
132-
133-
const rejected = auditResults.filter(isPromiseRejectedResult);
134-
if (rejected.length > 0) {
135-
rejected.forEach(result => {
136-
console.error(result.reason);
137-
});
138-
139-
throw new Error(`JS Packages plugin: Running ${pm.name} audit failed.`);
140-
}
141-
142-
const fulfilled = objectFromEntries(
143-
auditResults.filter(isPromiseFulfilledResult).map(x => x.value),
118+
const auditResults = await asyncSequential(
119+
compatibleAuditDepGroups,
120+
async (depGroup): Promise<[DependencyGroup, AuditResult]> => {
121+
const { stdout } = await executeProcess({
122+
command: pm.command,
123+
args: pm.audit.getCommandArgs(depGroup),
124+
cwd: packageJsonPath ? path.dirname(packageJsonPath) : process.cwd(),
125+
ignoreExitCode: pm.audit.ignoreExitCode,
126+
});
127+
return [depGroup, pm.audit.unifyResult(stdout)];
128+
},
144129
);
145130

146-
const uniqueResults = pm.audit.postProcessResult?.(fulfilled) ?? fulfilled;
131+
const resultsMap = objectFromEntries(auditResults);
132+
const uniqueResults = pm.audit.postProcessResult?.(resultsMap) ?? resultsMap;
147133

148134
return compatibleAuditDepGroups.map(depGroup =>
149135
auditResultToAuditOutput(

0 commit comments

Comments
 (0)