2013-12-06 18:13:15 +04:00
|
|
|
// General entry point for all configuration data
|
|
|
|
//
|
|
|
|
// This file itself is a wrapper for the root level config.js file.
|
|
|
|
// All other files that need to reference config.js should use this file.
|
2013-11-20 17:58:52 +04:00
|
|
|
|
2013-11-26 07:22:59 +04:00
|
|
|
var loader = require('./loader'),
|
|
|
|
paths = require('./paths'),
|
2013-12-06 18:13:15 +04:00
|
|
|
theme = require('./theme'),
|
2013-11-26 07:22:59 +04:00
|
|
|
ghostConfig;
|
2013-11-20 17:58:52 +04:00
|
|
|
|
2013-11-26 07:22:59 +04:00
|
|
|
// 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];
|
2013-11-20 17:58:52 +04:00
|
|
|
}
|
|
|
|
|
2013-11-26 07:22:59 +04:00
|
|
|
function loadConfig() {
|
|
|
|
return loader().then(function (config) {
|
|
|
|
// Cache the config.js object's environment
|
|
|
|
// object so we can later refer to it.
|
2014-01-03 00:27:09 +04:00
|
|
|
// Note: this is not the entirety of config.js,
|
2013-11-26 07:22:59 +04:00
|
|
|
// just the object appropriate for this NODE_ENV
|
|
|
|
ghostConfig = config;
|
2014-01-03 00:27:09 +04:00
|
|
|
|
|
|
|
// can't load theme settings yet as we don't have the API,
|
|
|
|
// but we can load the paths
|
|
|
|
return paths.update(config.url);
|
2013-11-26 07:22:59 +04:00
|
|
|
});
|
|
|
|
}
|
2013-11-20 17:58:52 +04:00
|
|
|
|
2013-11-26 07:22:59 +04:00
|
|
|
config.load = loadConfig;
|
|
|
|
config.paths = paths;
|
2013-12-06 18:13:15 +04:00
|
|
|
config.theme = theme;
|
2013-11-20 17:58:52 +04:00
|
|
|
|
2013-11-26 07:22:59 +04:00
|
|
|
module.exports = config;
|