Skip to content

Commit 2173691

Browse files
committed
feat(plugin-workspace-tools): report errors for all non-zero exit codes
1 parent 80052a0 commit 2173691

File tree

1 file changed

+9
-7
lines changed
  • packages/plugin-workspace-tools/sources/commands

1 file changed

+9
-7
lines changed

packages/plugin-workspace-tools/sources/commands/foreach.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ export default class WorkspacesForeachCommand extends BaseCommand {
405405
needsProcessing.delete(identHash);
406406
processing.delete(workspace.anchoredDescriptor.descriptorHash);
407407

408-
return exitCode;
408+
return {workspace, exitCode};
409409
}));
410410

411411
// If we're not executing processes in parallel we can just wait for it
@@ -424,13 +424,15 @@ export default class WorkspacesForeachCommand extends BaseCommand {
424424
return;
425425
}
426426

427-
const exitCodes: Array<number> = await Promise.all(commandPromises);
428-
const errorCode = exitCodes.find(code => code !== 0);
427+
const results: Array<{ workspace: Workspace, exitCode: number }> = await Promise.all(commandPromises);
428+
results.forEach(({workspace, exitCode}) => {
429+
if (exitCode !== 0) {
430+
report.reportError(MessageName.UNNAMED, `The command failed in workspace ${structUtils.prettyLocator(configuration, workspace.anchoredLocator)}`);
431+
}
432+
});
429433

430-
// The order in which the exit codes will be processed is fairly
431-
// opaque, so better just return a generic "1" for determinism.
432-
if (finalExitCode === null)
433-
finalExitCode = typeof errorCode !== `undefined` ? 1 : finalExitCode;
434+
const exitCodes = results.map(result => result.exitCode);
435+
const errorCode = exitCodes.find(code => code !== 0);
434436

435437
if ((this.topological || this.topologicalDev) && typeof errorCode !== `undefined`) {
436438
report.reportError(MessageName.UNNAMED, `The command failed for workspaces that are depended upon by other workspaces; can't satisfy the dependency graph`);

0 commit comments

Comments
 (0)