mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-25 09:37:35 +00:00
fix(shell): config: fix task race
This commit is contained in:
parent
4eeef19083
commit
92abde9af2
@ -16,7 +16,7 @@ import type { ChronocatConfig, ChronocatCurrentConfig } from './configEntity'
|
||||
|
||||
let config: ChronocatCurrentConfig | undefined = undefined
|
||||
|
||||
const loadConfig = async () => {
|
||||
const task = (async () => {
|
||||
const configDir = join(baseDir, 'config')
|
||||
const configPath = join(configDir, 'chronocat.yml')
|
||||
|
||||
@ -52,10 +52,10 @@ const loadConfig = async () => {
|
||||
const result = Object.assign({}, parsedConfig, parsedConfig.overrides?.[uin])
|
||||
if ('overrides' in result) delete result.overrides
|
||||
|
||||
return result
|
||||
}
|
||||
config = result
|
||||
})()
|
||||
|
||||
export const getConfig = async () => {
|
||||
if (!config) config = await loadConfig()
|
||||
return config
|
||||
await task
|
||||
return config!
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user