export default async (content )=>{
return new Promise((resolve,reject)=>{
const outputFile= join("temp",uuid1() + ".zip")
const archive = archiver('zip',{
level : 9
})
const writeStream = createWriteStream(outputFile);
writeStream.on("close",()=>{
resolve(outputFile)
})
writeStream.on("error",(err)=>{
if (err.code !== 'ENOENT') {
reject(err.message)
}
})
archive.pipe(writeStream)
if(content.type == TYPE.FOLDER){
archive.directory(content.path,content.mask)
}else {
archive.file(content.path,{name:basename(content.path)})
}
archive.finalize()
})
}
When test code on above with jest, archiver creates file named as "zip" along with the zip file on temp directory. Is there any way to prevent archiver create unnecessary zip file?