Skip to content

Commit

Permalink
removing promise wrap
Browse files Browse the repository at this point in the history
  • Loading branch information
vmjoseph committed Apr 8, 2024
1 parent 6e1d754 commit da5e926
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
36 changes: 17 additions & 19 deletions packages/artifact/src/internal/upload/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ export async function createZipUploadStream(
const zipUploadStream = new ZipUploadStream(bufferSize)
zip.pipe(zipUploadStream)
// register callbacks for various events during the zip lifecycle
zip.on('warning', zipWarningCallback)
zip.on('error', zipErrorCallback)
zip.on('warning', zipWarningCallback)
zip.on('finish', zipFinishCallback)
zip.on('end', zipEndCallback)

const addFileToZip = (
file: UploadZipSpecification,
callback: (error?: Error) => void
Expand Down Expand Up @@ -75,24 +74,23 @@ export async function createZipUploadStream(
}
}

return new Promise((resolve, reject) => {
async.eachSeries(uploadSpecification, addFileToZip, (error: unknown) => {
if (error) {
core.error('Failed to add a file to the zip:')
core.info(error.toString()) // Convert error to string
reject(error)
return
}
zip.finalize() // Finalize the archive once all files have been added
core.debug(
`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`
)
core.debug(
`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`
)
resolve(zipUploadStream)
})
async.eachSeries(uploadSpecification, addFileToZip, (error: unknown) => {
if (error) {
core.error('Failed to add a file to the zip:')
core.info(error.toString()) // Convert error to string
return
}
zip.finalize() // Finalize the archive once all files have been added
})

core.debug(
`Zip write high watermark value ${zipUploadStream.writableHighWaterMark}`
)
core.debug(
`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`
)

return zipUploadStream
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion packages/attest/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit da5e926

Please sign in to comment.