Advertisement
Guest User

Untitled

a guest
May 27th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. const streamBuffers = require('stream-buffers');
  2. const archiver = require('archiver');
  3.  
  4. const zipDir = (dir) => {
  5. const output = new streamBuffers.WritableStreamBuffer({
  6. initialSize: (100 * 1024), // start at 100 kilobytes.
  7. incrementAmount: (10 * 1024), // grow by 10 kilobytes each time buffer overflows.);
  8. });
  9. const archive = archiver('zip');
  10. archive.on('end', () => {
  11. done(null, output);
  12. });
  13. archive.on('error', done);
  14. archive.pipe(output);
  15. archive.directory(dir, '/');
  16. archive.finalize();
  17. };
  18.  
  19. zipDir(path.join(__dirname, 'path', 'to', 'directory'));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement