0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00
ghost/core/test/utils/configUtils.js
kirrg001 b158a3a944 🚨 change logic for test/utils/configUtils
refs #6982
- adaption because of using nconf
- change tests which changed config directly

[ci skip]
2016-09-20 15:59:34 +01:00

35 lines
866 B
JavaScript

var _ = require('lodash'),
config = require('../../server/config'),
configUtils = {};
configUtils.config = config;
configUtils.defaultConfig = _.cloneDeep(config.get());
/**
* configUtils.set({});
* configUtils.set('key', 'value');
*/
configUtils.set = function () {
var key = arguments[0],
value = arguments[1];
if (_.isObject(key)) {
_.each(key, function (value, key) {
config.set(key, value);
});
} else {
config.set(key, value);
}
};
/**
* important: do not delete cloneDeep for value
* nconf keeps this as a reference and then it can happen that the defaultConfig get's overridden by new values
*/
configUtils.restore = function () {
_.each(configUtils.defaultConfig, function (value, key) {
config.set(key, _.cloneDeep(value));
});
};
module.exports = configUtils;