mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Moved zip folder utility to services/themes
refs #9178 - it's only used for themes currently - this is definitely a util which could be useful lib - if we have a second use case, we can move it
This commit is contained in:
parent
fc5b4dd934
commit
849e97640f
3 changed files with 13 additions and 11 deletions
|
@ -6,7 +6,7 @@ var fs = require('fs-extra'),
|
|||
Promise = require('bluebird'),
|
||||
config = require('../../config'),
|
||||
security = require('../../lib/security'),
|
||||
zipFolder = require('../../utils/zip-folder'),
|
||||
localUtils = require('./utils'),
|
||||
LocalFileStorage = require('../../adapters/storage/LocalFileStorage');
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@ class ThemeStorage extends LocalFileStorage {
|
|||
|
||||
fs.ensureDir(zipBasePath)
|
||||
.then(function () {
|
||||
return Promise.promisify(zipFolder)(themePath, zipPath);
|
||||
return Promise.promisify(localUtils.zipFolder)(themePath, zipPath);
|
||||
})
|
||||
.then(function (length) {
|
||||
res.set({
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
var fs = require('fs-extra');
|
||||
'use strict';
|
||||
|
||||
module.exports = function zipFolder(folderToZip, destination, callback) {
|
||||
const fs = require('fs-extra');
|
||||
|
||||
exports.zipFolder = function zipFolder(folderToZip, destination, callback) {
|
||||
var archiver = require('archiver'),
|
||||
output = fs.createWriteStream(destination),
|
||||
archive = archiver.create('zip', {});
|
|
@ -2,13 +2,13 @@ var should = require('should'), // jshint ignore:line
|
|||
path = require('path'),
|
||||
fs = require('fs-extra'),
|
||||
extract = require('extract-zip'),
|
||||
zipFolder = require('../../../server/utils/zip-folder');
|
||||
themeUtils = require('../../../../server/services/themes/utils');
|
||||
|
||||
describe('Utils: zip-folder', function () {
|
||||
const symlinkPath = path.join(__dirname, '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink'),
|
||||
folderToSymlink = path.join(__dirname, '..', '..', 'utils', 'fixtures', 'themes', 'casper'),
|
||||
zipDestination = path.join(__dirname, '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink.zip'),
|
||||
unzipDestination = path.join(__dirname, '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink-unzipped');
|
||||
describe('services/themes: theme utils', function () {
|
||||
const symlinkPath = path.join(__dirname, '..', '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink'),
|
||||
folderToSymlink = path.join(__dirname, '..', '..', '..', 'utils', 'fixtures', 'themes', 'casper'),
|
||||
zipDestination = path.join(__dirname, '..', '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink.zip'),
|
||||
unzipDestination = path.join(__dirname, '..', '..', '..', 'utils', 'fixtures', 'themes', 'theme-symlink-unzipped');
|
||||
|
||||
before(function () {
|
||||
fs.removeSync(symlinkPath);
|
||||
|
@ -25,7 +25,7 @@ describe('Utils: zip-folder', function () {
|
|||
it('ensure symlinks work', function (done) {
|
||||
fs.symlink(folderToSymlink, symlinkPath);
|
||||
|
||||
zipFolder(symlinkPath, zipDestination, function (err) {
|
||||
themeUtils.zipFolder(symlinkPath, zipDestination, function (err) {
|
||||
if (err) {
|
||||
return done(err);
|
||||
}
|
Loading…
Reference in a new issue