Ghost/core/server/utils/zip-folder.js
Katharina Irrgang 7556e68c48 🎨 Ghost bootstrap: optimise requires (#8121)
* 🎨  Ghost bootstrap: optimise requires

no issue

- require as less as possible on bootstrap

* do not load icojs on bootstrap
2017-03-13 20:07:12 +00:00

20 lines
500 B
JavaScript

var fs = require('fs');
module.exports = function zipFolder(folderToZip, destination, callback) {
var archiver = require('archiver'),
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();
};