mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 11:55:03 +03:00
Moved out code from download to serve method
This commit is contained in:
parent
c3b14f82fd
commit
8709f5cc55
@ -66,5 +66,24 @@ const activate = (filePath) => {
|
||||
});
|
||||
};
|
||||
|
||||
const serve = () => {
|
||||
const routesPath = path.join(config.getContentPath('settings'), 'routes.yaml');
|
||||
|
||||
return fs.readFile(routesPath, 'utf-8')
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
if (common.errors.utils.isIgnitionError(err)) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
throw new common.errors.NotFoundError({
|
||||
err: err
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.activate = activate;
|
||||
// module.exports.serve = serve;
|
||||
module.exports.serve = serve;
|
||||
|
@ -1,8 +1,5 @@
|
||||
const Promise = require('bluebird');
|
||||
const _ = require('lodash');
|
||||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const config = require('../../config');
|
||||
const models = require('../../models');
|
||||
const frontendRouting = require('../../../frontend/services/routing');
|
||||
const common = require('../../lib/common');
|
||||
@ -168,22 +165,7 @@ module.exports = {
|
||||
method: 'browse'
|
||||
},
|
||||
query() {
|
||||
const routesPath = path.join(config.getContentPath('settings'), 'routes.yaml');
|
||||
|
||||
return fs.readFile(routesPath, 'utf-8')
|
||||
.catch((err) => {
|
||||
if (err.code === 'ENOENT') {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
if (common.errors.utils.isIgnitionError(err)) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
throw new common.errors.NotFoundError({
|
||||
err: err
|
||||
});
|
||||
});
|
||||
return frontendRouting.settings.serve();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user