Skip to content

Commit

Permalink
feat(plugin-workspace-tools): report errors for all non-zero exit codes
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Oct 3, 2024
1 parent 80052a0 commit 2173691
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/plugin-workspace-tools/sources/commands/foreach.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export default class WorkspacesForeachCommand extends BaseCommand {
needsProcessing.delete(identHash);
processing.delete(workspace.anchoredDescriptor.descriptorHash);

return exitCode;
return {workspace, exitCode};
}));

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

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

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

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

0 comments on commit 2173691

Please sign in to comment.