I want to use archiver (https://www.npmjs.com/package/archiver) To copy a whole folder into the zip file. here is my code.
I Don't know how to do this, I have tried researching but found nothing yet.
const fs = require('fs');
const archiver = require('archiver');
const output = fs.createWriteStream(__dirname + '/example.zip');
const archive = archiver('zip', {
zlib: { level: 9 } // Sets the compression level.
});
archive.on('error', function(err) {
throw err;
});
archive.pipe(output);
archive.file(`C:\\Users\\John\\Desktop\\MyFolder`, {name: 'MyFolder'});
archive.finalize();