mirror of
https://github.com/chrononeko/chronocat.git
synced 2024-11-29 02:57:17 +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
|
let config: ChronocatCurrentConfig | undefined = undefined
|
||||||
|
|
||||||
const loadConfig = async () => {
|
const task = (async () => {
|
||||||
const configDir = join(baseDir, 'config')
|
const configDir = join(baseDir, 'config')
|
||||||
const configPath = join(configDir, 'chronocat.yml')
|
const configPath = join(configDir, 'chronocat.yml')
|
||||||
|
|
||||||
@ -52,10 +52,10 @@ const loadConfig = async () => {
|
|||||||
const result = Object.assign({}, parsedConfig, parsedConfig.overrides?.[uin])
|
const result = Object.assign({}, parsedConfig, parsedConfig.overrides?.[uin])
|
||||||
if ('overrides' in result) delete result.overrides
|
if ('overrides' in result) delete result.overrides
|
||||||
|
|
||||||
return result
|
config = result
|
||||||
}
|
})()
|
||||||
|
|
||||||
export const getConfig = async () => {
|
export const getConfig = async () => {
|
||||||
if (!config) config = await loadConfig()
|
await task
|
||||||
return config
|
return config!
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user