From fbc4db42b5df1c68693d145c2063516ea135055c Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Tue, 3 Jul 2018 16:26:05 +1000 Subject: [PATCH] perf(publisher-nucleus): merge make results when arch/platform/version are all the same to speed up --- .../publisher/nucleus/src/PublisherNucleus.ts | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/packages/publisher/nucleus/src/PublisherNucleus.ts b/packages/publisher/nucleus/src/PublisherNucleus.ts index b138a86520..3aeda0c265 100644 --- a/packages/publisher/nucleus/src/PublisherNucleus.ts +++ b/packages/publisher/nucleus/src/PublisherNucleus.ts @@ -14,11 +14,30 @@ const d = debug('electron-forge:publish:nucleus'); export default class PublisherNucleus extends PublisherBase { 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 () => {