Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
perf(publisher-nucleus): merge make results when arch/platform/versio…
…n are all the same to speed up
  • Loading branch information
MarshallOfSound committed Jul 3, 2018
1 parent 25f6777 commit fbc4db4
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/publisher/nucleus/src/PublisherNucleus.ts
Expand Up @@ -14,11 +14,30 @@ const d = debug('electron-forge:publish:nucleus');
export default class PublisherNucleus extends PublisherBase<PublisherNucleusConfig> {
name = 'nucleus';

private collapseMakeResults = (makeResults: PublisherOptions['makeResults']) => {
const newMakeResults: typeof makeResults = [];
for (const result of makeResults) {
const existingResult = newMakeResults.find((nResult) => {
return nResult.arch === result.arch
&& nResult.platform === result.platform
&& nResult.packageJSON.version === result.packageJSON.version;
});
if (existingResult) {
existingResult.artifacts.push(...result.artifacts);
} else {
newMakeResults.push({ ...result });
}
}
return newMakeResults;
}

async publish({ makeResults }: PublisherOptions) {
const { config } = this;

for (const [i, makeResult] of makeResults.entries()) {
const msg = `Uploading result (${i}/${makeResults.length})`;
const collapsedResults = this.collapseMakeResults(makeResults);

for (const [i, makeResult] of collapsedResults.entries()) {
const msg = `Uploading result (${i + 1}/${collapsedResults.length})`;
d(msg);

await asyncOra(msg, async () => {
Expand Down

0 comments on commit fbc4db4

Please sign in to comment.