I am generating a zip file using the module archiver
. I want to wait for the zip file to be generated before proceeding further. Below is the relevant part of the code.
// create a file to stream archive data to.
const archiver = require('archiver');
const fs = require('fs');
async function zipcsv(zipPath) {
let output = fs.createWriteStream(zipPath);
let archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
});
output.on('close', function() {
return 'zip generating complete';
});
archive.pipe(output);
archive.directory('exports/', false);
archive.finalize();
}
module.exports.zipcsv = zipcsv;
zip = require('./zipcsv')
await zip.zipcsv(path);
console.log('futher processing');
I see futher processing on the console and the process does not wait for the zip to be generated and continues.
How can I ensure that the zip is generated and then further processing continues.
Thanks.