You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
628 B
24 lines
628 B
import { loadConfig as loadConfigFn } from 'unconfig'
|
|
import type { DMConfig } from './type'
|
|
|
|
let tempConfig: Awaited<ReturnType<typeof loadConfigFn<DMConfig>>> | undefined
|
|
|
|
export const loadConfig = async <T extends DMConfig>() => {
|
|
return loadConfigFn<T>({
|
|
sources: [
|
|
{
|
|
files: 'dm.config',
|
|
extensions: ['ts', 'mts', 'cts', 'js', 'mjs', 'cjs', 'json', ''],
|
|
}
|
|
],
|
|
merge: false,
|
|
})
|
|
}
|
|
|
|
export const getConfig = async () => {
|
|
if (!tempConfig) {
|
|
tempConfig = await loadConfig()
|
|
}
|
|
return tempConfig
|
|
}
|
|
|
|
|