1
0
Fork 0

cleaning up callback methods

pull/1700/head
Vallie Joseph 2024-03-28 16:15:29 +00:00
parent d97edf7f61
commit 088b9761b4
1 changed files with 16 additions and 27 deletions

View File

@ -34,22 +34,11 @@ export async function createZipUploadStream(
} }
const zip = new ZipStream.default(zlibOptions) const zip = new ZipStream.default(zlibOptions)
// register callbacks for various events during the zip lifecycle // register callbacks for various events during the zip lifecycle
zip.on('error', err => { zip.on('error', zipErrorCallback)
core.error('An error has occurred while creating the zip file for upload')
core.info(err)
throw new Error(
'An error has occurred during zip creation for the artifact'
)
})
zip.on('warning', zipWarningCallback) zip.on('warning', zipWarningCallback)
zip.on('finish', () => { zip.on('finish', zipFinishCallback)
core.debug('Zip stream for upload has finished.') zip.on('end', zipEndCallback)
})
zip.on('end', () => {
core.debug('Zip stream for upload has ended.')
})
for (const file of uploadSpecification) { for (const file of uploadSpecification) {
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
@ -82,18 +71,18 @@ export async function createZipUploadStream(
core.debug( core.debug(
`Zip read high watermark value ${zipUploadStream.readableHighWaterMark}` `Zip read high watermark value ${zipUploadStream.readableHighWaterMark}`
) )
// zip.pipe(zipUploadStream)
zip.finalize() zip.finalize()
return zipUploadStream return zipUploadStream
} }
// const zipErrorCallback = (error: any): void => { // eslint-disable-next-line @typescript-eslint/no-explicit-any
// core.error('An error has occurred while creating the zip file for upload') const zipErrorCallback = (error: any): void => {
// core.info(error) core.error('An error has occurred while creating the zip file for upload')
core.info(error)
// throw new Error('An error has occurred during zip creation for the artifact') throw new Error('An error has occurred during zip creation for the artifact')
// } }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const zipWarningCallback = (err: any): void => { const zipWarningCallback = (err: any): void => {
if (err.code === 'ENOENT') { if (err.code === 'ENOENT') {
core.warning( core.warning(
@ -108,10 +97,10 @@ const zipWarningCallback = (err: any): void => {
} }
} }
// const zipFinishCallback = (): void => { const zipFinishCallback = (): void => {
// core.debug('Zip stream for upload has finished.') core.debug('Zip stream for upload has finished.')
// } }
// const zipEndCallback = (): void => { const zipEndCallback = (): void => {
// core.debug('Zip stream for upload has ended.') core.debug('Zip stream for upload has ended.')
// } }