diff --git a/ghost/zip/index.js b/ghost/zip/index.js index b93c4fd013..4024126cd2 100644 --- a/ghost/zip/index.js +++ b/ghost/zip/index.js @@ -1,8 +1,7 @@ -const Promise = require('bluebird'); -const extract = require('@tryghost/extract-zip'); +const extract = require('extract-zip'); const zipFolder = require('./lib/zip-folder'); module.exports = { - zipFolder: Promise.promisify(zipFolder), - extract: Promise.promisify(extract) + extract, + zipFolder }; diff --git a/ghost/zip/lib/zip-folder.js b/ghost/zip/lib/zip-folder.js index b797a0eba9..045e12af5c 100644 --- a/ghost/zip/lib/zip-folder.js +++ b/ghost/zip/lib/zip-folder.js @@ -1,6 +1,7 @@ const fs = require('fs-extra'); +const Promise = require('bluebird'); -module.exports = function zipFolder(folderToZip, destination, callback) { +const zipFolder = (folderToZip, destination, callback) => { var archiver = require('archiver'), output = fs.createWriteStream(destination), archive = archiver.create('zip', {}); @@ -25,3 +26,5 @@ module.exports = function zipFolder(folderToZip, destination, callback) { archive.pipe(output); archive.finalize(); }; + +module.exports = Promise.promisify(zipFolder); diff --git a/ghost/zip/package.json b/ghost/zip/package.json index b71538289a..18f3b2720d 100644 --- a/ghost/zip/package.json +++ b/ghost/zip/package.json @@ -24,9 +24,9 @@ "sinon": "9.0.1" }, "dependencies": { - "@tryghost/extract-zip": "^1.6.6", "archiver": "^3.1.1", "bluebird": "^3.7.2", + "extract-zip": "^2.0.0", "fs-extra": "^9.0.0" } } diff --git a/ghost/zip/test/zip-folder.test.js b/ghost/zip/test/zip-folder.test.js index 2b9be7fc3b..64c4951e8a 100644 --- a/ghost/zip/test/zip-folder.test.js +++ b/ghost/zip/test/zip-folder.test.js @@ -4,10 +4,9 @@ require('./utils'); const path = require('path'); const fs = require('fs-extra'); -const extract = require('@tryghost/extract-zip'); // Mimic how we expect this to be required -const {zipFolder} = require('../'); +const {zipFolder, extract} = require('../'); describe('lib/fs: read csv', function () { let symlinkPath, folderToSymlink, zipDestination, unzipDestination; @@ -34,25 +33,25 @@ describe('lib/fs: read csv', function () { it('ensure symlinks work', function (done) { fs.symlink(folderToSymlink, symlinkPath); - zipFolder(symlinkPath, zipDestination, function (err) { - if (err) { - return done(err); - } + zipFolder(symlinkPath, zipDestination) + .then(() => { + extract(zipDestination, {dir: unzipDestination}) + .then(() => { + fs.readdir(unzipDestination, function (err, files) { + if (err) { + return done(err); + } - extract(zipDestination, {dir: unzipDestination}, function (err) { - if (err) { - return done(err); - } - - fs.readdir(unzipDestination, function (err, files) { - if (err) { + files.length.should.eql(16); + done(); + }); + }) + .catch((err) => { return done(err); - } - - files.length.should.eql(16); - done(); - }); + }); + }) + .catch((err) => { + return done(err); }); - }); }); });