Ghost/core/index.js
Harry Wolff 5ff2a31ce1 Move Models module to have an init method that sets up all models
resolves #2170

- creates a models.init() function that requires all other model files
and caches them.  This is opposed to the previous functionality where
when you require('./models') it would immediately require all other models.
Now it's done when you want.

- Updates all tests to reflect the new structure of the model module
2014-08-18 15:54:10 -04:00

34 lines
957 B
JavaScript

// # Ghost bootloader
// Orchestrates the loading of Ghost
// When run from command line.
var when = require('when'),
bootstrap = require('./bootstrap'),
server = require('./server');
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
function startGhost(options) {
var deferred = when.defer();
options = options || {};
bootstrap(options.config).then(function () {
try {
return server(options.app)
.then(deferred.resolve)
.catch(function (err) {
// We don't return the rejected promise to stop
// the propagation of the rejection and just
// allow the user to manage what to do.
deferred.reject(err);
});
} catch (e) {
deferred.reject(e);
}
}).catch(deferred.reject);
return deferred.promise;
}
module.exports = startGhost;