baa8118893
- Use array destructuring - Use @tryghost/errors - Part of the big move towards decoupling, this gives visibility on what's being used where - Biting off manageable chunks / fixing bits of code I'm refactoring for other reasons
27 lines
788 B
JavaScript
27 lines
788 B
JavaScript
// ## Server Loader
|
|
// Passes options through the boot process to get a server instance back
|
|
const server = require('./server');
|
|
const errors = require('@tryghost/errors');
|
|
const GhostServer = require('./server/ghost-server');
|
|
|
|
// Set the default environment to be `development`
|
|
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
|
|
|
function makeGhost(options) {
|
|
options = options || {};
|
|
|
|
return server(options)
|
|
.catch((err) => {
|
|
if (!errors.utils.isIgnitionError(err)) {
|
|
err = new errors.GhostError({message: err.message, err: err});
|
|
}
|
|
|
|
return GhostServer.announceServerStopped(err)
|
|
.finally(() => {
|
|
throw err;
|
|
});
|
|
});
|
|
}
|
|
|
|
module.exports = makeGhost;
|