Skip to content

Commit

Permalink
refactor: use set for perf reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Nov 20, 2023
1 parent 5659050 commit daab406
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/formatters/deployResultFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,18 +272,19 @@ export class DeployResultFormatter extends TestResultsFormatter implements Forma
const failures = this.relativeFiles.filter(isSdrFailure);
const deployMessages = ensureArray(this.result.response.details?.componentFailures);
if (deployMessages.length > failures.length) {
const failureKeySet = new Set(failures.map((f) => makeKey(f.type, f.fullName)));
// if there's additional failures in the API response, find the failure and add it to the output
deployMessages.map((deployMessage) => {
if (!failures.some((f) => f.type === deployMessage.componentType && f.fullName === deployMessage.fullName)) {
deployMessages
.filter((m) => !m.componentType || !failureKeySet.has(makeKey(m.componentType, m.fullName)))
.map((deployMessage) => {
failures.push({
fullName: deployMessage.fullName,
type: deployMessage.componentType ?? 'UNKNOWN',
state: ComponentStatus.Failed,
error: deployMessage.problem ?? 'UNKNOWN',
problemType: deployMessage.problemType ?? 'Error',
});
}
});
});
}
if (!failures.length) return;

Expand Down Expand Up @@ -324,3 +325,5 @@ export class DeployResultFormatter extends TestResultsFormatter implements Forma
ux.table(getFileResponseSuccessProps(deletions), columns, options);
}
}

const makeKey = (type: string, name: string): string => `${type}#${name}`;

0 comments on commit daab406

Please sign in to comment.