Ghost/core/server/utils/zip-folder.js
Hannah Wolfe 545d2cb8b0 Use node-archiver to create zips (#7268)
closes #7266, closes #7267

- Adds node-archiver as a dependency
- Adds new zip-folder utility
- Switch out exec 'zip' for zip folder utility
- Store generated zips in os.tmpdir
- Don't delete zips from content/themes when uploading or deleting
- Fixes path resolution for delete
2016-08-25 09:22:22 +02:00

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();
};