Ghost/core/server/config/index.js

28 lines
851 B
JavaScript

var loader = require('./loader'),
paths = require('./paths'),
ghostConfig;
// Returns NODE_ENV config object
function config() {
// @TODO: get rid of require statement.
// This is currently needed for tests to load config file
// successfully. While running application we should never
// have to directly delegate to the config.js file.
return ghostConfig || require(paths().config)[process.env.NODE_ENV];
}
function loadConfig() {
return loader().then(function (config) {
// Cache the config.js object's environment
// object so we can later refer to it.
// Note: this is not the entirity of config.js,
// just the object appropriate for this NODE_ENV
ghostConfig = config;
});
}
config.load = loadConfig;
config.paths = paths;
module.exports = config;