mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-01 13:54:35 +03:00
545d2cb8b0
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
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();
|
|
};
|
|
|