🐞 fix: Update config file handling

This commit is contained in:
Keith Solomon
2026-05-16 15:23:40 -05:00
parent e7748d3307
commit cb568597dc
2 changed files with 32 additions and 1 deletions
+10 -1
View File
@@ -111,12 +111,21 @@ function camelize(value: unknown): unknown {
return value;
}
function objectFromNull(value: unknown): unknown {
return value === null ? {} : value;
}
export function expandHome(path: string): string {
return path.startsWith('~/') ? resolve(homedir(), path.slice(2)) : path;
}
export function loadConfigFromString(source: string): AppConfig {
const parsed = camelize(YAML.parse(source) ?? {});
const parsed = camelize(YAML.parse(source) ?? {}) as Record<string, any>;
parsed.newsletters = objectFromNull(parsed.newsletters);
parsed.categories = objectFromNull(parsed.categories) as Record<string, any>;
if (parsed.categories && typeof parsed.categories === 'object') {
parsed.categories.llm = objectFromNull(parsed.categories.llm);
}
return configSchema.parse(parsed);
}