Files
Homarr/src/tools/config/getConfig.ts

19 lines
698 B
TypeScript
Raw Normal View History

2022-12-22 11:29:51 +09:00
import { BackendConfigType } from '../../types/config';
2022-12-11 14:11:25 +01:00
import { configExists } from './configExists';
import { getFallbackConfig } from './getFallbackConfig';
2022-12-22 11:29:51 +09:00
import { migrateConfig } from './migrateConfig';
2022-12-11 14:11:25 +01:00
import { readConfig } from './readConfig';
export const getConfig = (name: string): BackendConfigType => {
2022-12-11 14:11:25 +01:00
if (!configExists(name)) return getFallbackConfig();
2022-12-22 11:29:51 +09:00
// Else if config exists but contains no "schema_version" property
// then it is an old config file and we should try to migrate it
// to the new format.
let config = readConfig(name);
if (!config.schemaVersion) {
// TODO: Migrate config to new format
config = migrateConfig(config);
}
return config;
2022-12-11 14:11:25 +01:00
};