Last active
December 18, 2017 19:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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