mirror of
https://gh.catmak.name/https://github.com/mihomo-party-org/mihomo-party
synced 2025-12-26 20:50:30 +08:00
fix: ensure all default config fields are present in config.yaml
This commit is contained in:
parent
508d7d63c9
commit
392285058e
@ -9,7 +9,13 @@ let appConfig: IAppConfig // config.yaml
|
||||
export async function getAppConfig(force = false): Promise<IAppConfig> {
|
||||
if (force || !appConfig) {
|
||||
const data = await readFile(appConfigPath(), 'utf-8')
|
||||
appConfig = parse(data) || defaultConfig
|
||||
const parsedConfig = parse(data)
|
||||
const mergedConfig = deepMerge({ ...defaultConfig }, parsedConfig || {})
|
||||
if (JSON.stringify(mergedConfig) !== JSON.stringify(parsedConfig)) {
|
||||
await writeFile(appConfigPath(), stringify(mergedConfig))
|
||||
}
|
||||
|
||||
appConfig = mergedConfig
|
||||
}
|
||||
if (typeof appConfig !== 'object') appConfig = defaultConfig
|
||||
return appConfig
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user