2017-01-20 13:03:18 +00:00
|
|
|
const configDefinitions = require('./definitions');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
getDefault,
|
|
|
|
getConfig,
|
|
|
|
};
|
|
|
|
|
|
|
|
const defaultValues = {
|
|
|
|
boolean: true,
|
|
|
|
list: [],
|
|
|
|
string: null,
|
2017-07-01 04:44:41 +00:00
|
|
|
json: null,
|
2017-01-20 13:03:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
function getDefault(option) {
|
2017-04-21 08:12:41 +00:00
|
|
|
return option.default === undefined
|
|
|
|
? defaultValues[option.type]
|
|
|
|
: option.default;
|
2017-01-20 13:03:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getConfig() {
|
|
|
|
const options = configDefinitions.getOptions();
|
|
|
|
const config = {};
|
2017-04-21 08:12:41 +00:00
|
|
|
options.forEach(option => {
|
2018-05-06 06:29:38 +00:00
|
|
|
if (!option.parent) {
|
2018-05-03 12:07:20 +00:00
|
|
|
config[option.name] = getDefault(option);
|
|
|
|
}
|
2017-01-20 13:03:18 +00:00
|
|
|
});
|
2017-06-26 11:08:57 +00:00
|
|
|
return config;
|
|
|
|
}
|