2016-09-13 18:20:44 +03:00
|
|
|
var nconf = require('nconf'),
|
|
|
|
path = require('path'),
|
|
|
|
localUtils = require('./utils'),
|
2016-09-13 21:37:19 +03:00
|
|
|
packageInfo = require('../../../package.json'),
|
2016-09-13 18:20:44 +03:00
|
|
|
env = process.env.NODE_ENV || 'development';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* command line arguments
|
|
|
|
*/
|
|
|
|
nconf.argv();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* env arguments
|
|
|
|
*/
|
2016-10-10 12:43:17 +03:00
|
|
|
nconf.env({
|
|
|
|
separator: '__'
|
|
|
|
});
|
2016-09-13 18:20:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* load config files
|
2016-10-05 17:55:39 +03:00
|
|
|
* @TODO:
|
|
|
|
* - why does this work? i have no idea!
|
|
|
|
* - find out why argv override works, when defining these weird keys
|
|
|
|
* - i could not find any nconf usages so that all config requirements work
|
2016-09-13 18:20:44 +03:00
|
|
|
*/
|
2016-10-05 17:55:39 +03:00
|
|
|
nconf.file('ghost1', __dirname + '/overrides.json');
|
|
|
|
nconf.file('ghost2', path.join(process.cwd(), 'config.' + env + '.json'));
|
|
|
|
nconf.file('ghost3', __dirname + '/env/config.' + env + '.json');
|
|
|
|
nconf.file('ghost4', __dirname + '/defaults.json');
|
2016-09-13 18:20:44 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* transform all relative paths to absolute paths
|
|
|
|
*/
|
|
|
|
localUtils.makePathsAbsolute.bind(nconf)();
|
|
|
|
|
2016-09-13 21:37:19 +03:00
|
|
|
/**
|
|
|
|
* values we have to set manual
|
|
|
|
* @TODO: ghost-cli?
|
|
|
|
*/
|
|
|
|
nconf.set('ghostVersion', packageInfo.version);
|
2016-10-06 15:27:35 +03:00
|
|
|
nconf.set('env', env);
|
2016-09-13 21:37:19 +03:00
|
|
|
|
2016-09-13 18:20:44 +03:00
|
|
|
module.exports = nconf;
|
|
|
|
module.exports.isPrivacyDisabled = localUtils.isPrivacyDisabled.bind(nconf);
|
2016-09-13 23:24:57 +03:00
|
|
|
module.exports.getContentPath = localUtils.getContentPath.bind(nconf);
|