Skip to content

Instantly share code, notes, and snippets.

@LironHazan
Last active December 18, 2017 19:49
Show Gist options
  • Save LironHazan/b98e4ab0806e06eebfc056159fccfb2f to your computer and use it in GitHub Desktop.
Save LironHazan/b98e4ab0806e06eebfc056159fccfb2f to your computer and use it in GitHub Desktop.
zip a folder code snippet I refactored based on tarzg function I used in a node backend project few years ago
const zipit = (dest, name) => {
const filePath = path.join(dest, name + '.zip');
const output = fs.createWriteStream(filePath);
const archive = archiver('zip', { zlib: { level: 9 } });
archive.pipe(output);
// callback
output.on('close', () => {
console.log('callback when everything is finished');
});
archive.directory('deploy/', false);
archive.finalize();
};
zipit('build' , 'build');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment