mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
21 lines
497 B
JavaScript
21 lines
497 B
JavaScript
|
var archiver = require('archiver'),
|
||
|
fs = require('fs');
|
||
|
|
||
|
module.exports = function zipFolder(folderToZip, destination, callback) {
|
||
|
var output = fs.createWriteStream(destination),
|
||
|
archive = archiver.create('zip', {});
|
||
|
|
||
|
output.on('close', function () {
|
||
|
callback(null, archive.pointer());
|
||
|
});
|
||
|
|
||
|
archive.on('error', function (err) {
|
||
|
callback(err, null);
|
||
|
});
|
||
|
|
||
|
archive.directory(folderToZip, '/');
|
||
|
archive.pipe(output);
|
||
|
archive.finalize();
|
||
|
};
|
||
|
|