Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const streamBuffers = require('stream-buffers');
- const archiver = require('archiver');
- const zipDir = (dir) => {
- const output = new streamBuffers.WritableStreamBuffer({
- initialSize: (100 * 1024), // start at 100 kilobytes.
- incrementAmount: (10 * 1024), // grow by 10 kilobytes each time buffer overflows.);
- });
- const archive = archiver('zip');
- archive.on('end', () => {
- done(null, output);
- });
- archive.on('error', done);
- archive.pipe(output);
- archive.directory(dir, '/');
- archive.finalize();
- };
- zipDir(path.join(__dirname, 'path', 'to', 'directory'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement