Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ type ConfigKeys = keyof typeof configParsers;

type RawConfig = {
[key in ConfigKeys]?: string;
} & {
// Backwards compatibility for config files written before MODEL was
// promoted to the canonical uppercase key.
model?: string;
};

type ValidConfig = {
Expand Down Expand Up @@ -92,7 +96,10 @@ export const getConfig = async (

for (const key of Object.keys(configParsers) as ConfigKeys[]) {
const parser = configParsers[key];
const value = cliConfig?.[key] ?? config[key];
const value =
key === 'MODEL'
? cliConfig?.MODEL ?? cliConfig?.model ?? config.MODEL ?? config.model
: cliConfig?.[key] ?? config[key];
parsedConfig[key] = parser(value);
}

Expand All @@ -109,6 +116,10 @@ export const setConfigs = async (keyValues: [key: string, value: string][]) => {

const parsed = configParsers[key as ConfigKeys](value);
config[key as ConfigKeys] = parsed as any;

if (key === 'MODEL') {
delete config.model;
}
}

await fs.writeFile(configPath, ini.stringify(config), 'utf8');
Expand Down