0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00
ghost/core/server/config/index.js
Katharina Irrgang 637d177cac 🎨 operate on separate nconf instance (#7528)
refs #7488

- if multiple projects use nconf, they all operate on the same cached nconf instance
- that can cause trouble
2016-10-10 13:04:00 +01:00

46 lines
1.2 KiB
JavaScript

var Nconf = require('nconf'),
nconf = new Nconf.Provider(),
path = require('path'),
localUtils = require('./utils'),
packageInfo = require('../../../package.json'),
env = process.env.NODE_ENV || 'development';
/**
* command line arguments
*/
nconf.argv();
/**
* env arguments
*/
nconf.env({
separator: '__'
});
/**
* load config files
* @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
*/
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');
/**
* transform all relative paths to absolute paths
*/
localUtils.makePathsAbsolute.bind(nconf)();
/**
* values we have to set manual
* @TODO: ghost-cli?
*/
nconf.set('ghostVersion', packageInfo.version);
nconf.set('env', env);
module.exports = nconf;
module.exports.isPrivacyDisabled = localUtils.isPrivacyDisabled.bind(nconf);
module.exports.getContentPath = localUtils.getContentPath.bind(nconf);