2016-10-10 14:04:00 +02:00
|
|
|
var Nconf = require('nconf'),
|
|
|
|
nconf = new Nconf.Provider(),
|
2016-09-13 17:20:44 +02:00
|
|
|
path = require('path'),
|
|
|
|
localUtils = require('./utils'),
|
|
|
|
env = process.env.NODE_ENV || 'development';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* command line arguments
|
|
|
|
*/
|
|
|
|
nconf.argv();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* env arguments
|
|
|
|
*/
|
2016-10-10 11:43:17 +02:00
|
|
|
nconf.env({
|
|
|
|
separator: '__'
|
|
|
|
});
|
2016-09-13 17:20:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* load config files
|
2016-10-05 16:55:39 +02: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 17:20:44 +02:00
|
|
|
*/
|
2016-10-05 16:55:39 +02: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 17:20:44 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* transform all relative paths to absolute paths
|
2016-10-18 10:04:44 +02:00
|
|
|
* transform sqlite filename path for Ghost-CLI
|
2016-09-13 17:20:44 +02:00
|
|
|
*/
|
2016-10-18 10:04:44 +02:00
|
|
|
localUtils.makePathsAbsolute.bind(nconf)(nconf.get('paths'), 'paths');
|
|
|
|
localUtils.makePathsAbsolute.bind(nconf)(nconf.get('database:connection'), 'database:connection');
|
2016-09-13 17:20:44 +02:00
|
|
|
|
2016-09-13 20:37:19 +02:00
|
|
|
/**
|
|
|
|
* values we have to set manual
|
|
|
|
*/
|
2016-10-06 14:27:35 +02:00
|
|
|
nconf.set('env', env);
|
2016-09-13 20:37:19 +02:00
|
|
|
|
2016-09-13 17:20:44 +02:00
|
|
|
module.exports = nconf;
|
|
|
|
module.exports.isPrivacyDisabled = localUtils.isPrivacyDisabled.bind(nconf);
|
2016-09-13 22:24:57 +02:00
|
|
|
module.exports.getContentPath = localUtils.getContentPath.bind(nconf);
|