Files
renovate/lib/config/inherit.ts
RahulGautamSingh 36f9d4a185 refactor: move requireConfig to InheritConfig (#41385)
* refactor: move requireConfig to InheritConfig

* fix test

* update test

* refactor
2026-04-14 11:53:53 +00:00

50 lines
1.2 KiB
TypeScript

import type { GlobalInheritableConfig, RenovateConfig } from './types.ts';
export const NOT_PRESENT = Symbol('not-present');
export class InheritConfig {
static OPTIONS: readonly (keyof GlobalInheritableConfig)[] = [
'bbUseDevelopmentBranch',
'configFileNames',
'onboarding',
'onboardingAutoCloseAge',
'onboardingBranch',
'onboardingCommitMessage',
'onboardingConfig',
'onboardingConfigFileName',
'onboardingNoDeps',
'onboardingPrTitle',
'requireConfig',
];
private static config: GlobalInheritableConfig = {};
static get<Key extends keyof GlobalInheritableConfig>(
key: Key,
): GlobalInheritableConfig[Key] | typeof NOT_PRESENT {
if (key in InheritConfig.config) {
return InheritConfig.config[key];
}
return NOT_PRESENT;
}
static set(config: RenovateConfig & GlobalInheritableConfig): RenovateConfig {
InheritConfig.reset();
const result = { ...config };
for (const option of InheritConfig.OPTIONS) {
if (option in config) {
InheritConfig.config[option] = config[option] as never;
}
delete result[option];
}
return result;
}
static reset(): void {
InheritConfig.config = {};
}
}