I want update file in zip arhive with nodejs
. For example i have zip file with two files:
a.zip
|-a.txt
|-b.txt
I use archiver:
var archiver = require('archiver');
var archive = archiver('zip', {});
archive.pipe(fs.createWriteStream('./a.zip'));
archive.append(fs.createReadStream('./c.txt'), { name: 't.txt' });
archive.finalize();
But I have a problem, my archive is completely overwritten. As a result, I get:
a.zip
|-t.txt
If I use:
archive.file('./a.txt', { name: 't.txt' });
the result remains the same. And I want to get this structure as a result
a.zip
|-a.txt
|-b.txt
|-t.txt
Or update the contents of one of the files a.txt
or b.txt