renovate/lib/config/defaults.ts

27 lines
587 B
TypeScript
Raw Normal View History

import { getOptions } from './options';
2021-06-02 09:25:10 +00:00
import type { AllConfig, RenovateOptions } from './types';
const defaultValues = {
boolean: true,
array: [],
string: null,
object: null,
};
2019-08-23 13:46:31 +00:00
export function getDefault(option: RenovateOptions): any {
2017-04-21 08:12:41 +00:00
return option.default === undefined
? defaultValues[option.type]
: option.default;
}
2021-06-02 09:25:10 +00:00
export function getConfig(): AllConfig {
2019-08-23 13:46:31 +00:00
const options = getOptions();
2021-06-02 09:25:10 +00:00
const config: AllConfig = {};
options.forEach((option) => {
if (!option.parent) {
config[option.name] = getDefault(option);
}
});
return config;
}