Getting duplicate parent zip upon extracting
Hello all, Hope you guys are well and safe. Need some help.
I have written below for zipping a directory :
const archiver = require('archiver');
let createArchive = function(sourceDir, destDir) {
const archive = archiver('zip');
const stream = fs.createWriteStream(destDir);
return new Promise((resolve, reject) => {
archive
.directory(sourceDir, false)
.on('error', err => reject(err))
.pipe(stream)
;
stream.on('close', () => resolve());
archive.finalize();
});
}
Before zipping my directory looked like this :
After zipping it looked like this

Now when i unzipped the final result looks like this :
The problem is after extracting i can see the duplicate yayy.zip upon opening which it gives me following error.

What i am missing ? Is there a way to achieve it without diverting much from my approach, i want to know the issue.
Thank you.
The .directory() method is working recursive. If this archiver created .zip file when not finish all progress, it is possible to be duplicate .zip in .zip file.
It is better to set .zip destination on different folder or do not use .directory() that can be included location where .zip will be created.