Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function finishWorksheetsAndArchive(
exports: Array,
dir: string,
output: stream$Writable,
logger: Object
) {
if (exports.length === 0) return archiveDir(dir, output, logger)
const writeStreams: Array = exports.map(
exportInfo => exportInfo.excel.stream
)
onStreamsFinished(writeStreams, err => {
if (err) {
logger.error(err)
output.emit('error', err)
} else {
archiveDir(dir, output, logger)
logger.info('All products have been written to ZIP file')
}
})
// close all excel workbooks
return exports
.map((exportInfo: Object): Object => exportInfo.excel)
.forEach((excel: Object) => excel.finish())
}