I'm using the unzip
module from npm to extract the contents of a zip archive. I need to know when it is done extracting and the file has been completely written to disk.
fs.createReadStream('master.zip').pipe(unzip.Extract({ path: 'gitdownloads/repo' }));
My first thought was that I could tap into the stream and listen for the finish event, but unzip
only takes input: it doesn't return another stream.
I also looked to see if the unzip
module had a "finish" callback. No luck.
Inside the loop, you convert the object into a string that represents the object using the Node. js toString() method, then log it in the console using the console. log() method. Finally, you invoke the readZipArchive() function with the ZIP archive file path as an argument.
ADM-ZIP is a pure JavaScript implementation for zip data compression for NodeJS. The library allows you to: decompress zip files directly to disk or in-memory buffers.
From the github README
Extract emits the 'close' event once the zip's contents have been fully extracted to disk.
You'll want to do something like:
fs.createReadStream('master.zip')
.pipe(unzip.Extract({ path: 'gitdownloads/repo' }))
.on('close', function () {
...
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With