mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 20:03:12 +03:00
Switch to OG extract-zip w/ promise based interface
- switch back from @tryghost/extract-zip to extract-zip now that it has been fixed (and is much better maintained) - switch the internal interface to be fully promise-based and test promise-based too
This commit is contained in:
parent
fec30521ad
commit
62c2fce6cc
@ -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
|
||||
};
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user