From 92996632972afaa630dcadd73af02b4db0af9f20 Mon Sep 17 00:00:00 2001 From: Vallie Joseph Date: Thu, 28 Mar 2024 17:13:32 +0000 Subject: [PATCH] adding promise all --- packages/artifact/src/internal/upload/zip.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/artifact/src/internal/upload/zip.ts b/packages/artifact/src/internal/upload/zip.ts index 3aff9e36..df7230fa 100644 --- a/packages/artifact/src/internal/upload/zip.ts +++ b/packages/artifact/src/internal/upload/zip.ts @@ -40,8 +40,9 @@ export async function createZipUploadStream( zip.on('finish', zipFinishCallback) zip.on('end', zipEndCallback) - for (const file of uploadSpecification) { - await new Promise((resolve, reject) => { + // for (const file of uploadSpecification) { + const fileUploadPromesses = uploadSpecification.map(async file => { + return new Promise((resolve, reject) => { if (file.sourcePath !== null) { // Add a normal file to the zip zip.entry( @@ -61,7 +62,7 @@ export async function createZipUploadStream( }) } }) - } + }) const bufferSize = getUploadChunkSize() const zipUploadStream = new ZipUploadStream(bufferSize) @@ -71,8 +72,12 @@ export async function createZipUploadStream( core.debug( `Zip read high watermark value ${zipUploadStream.readableHighWaterMark}` ) - zip.finalize() - return zipUploadStream + await Promise.all(fileUploadPromesses).then(() => { + zip.finalize() + + return zipUploadStream + }) + return Promise.reject(zipUploadStream) } // eslint-disable-next-line @typescript-eslint/no-explicit-any