后端拆分运行时配置模块

This commit is contained in:
yml
2026-05-21 14:06:49 +08:00
parent 5753971c92
commit 84ca9cac09
5 changed files with 177 additions and 172 deletions
+15
View File
@@ -0,0 +1,15 @@
import fs from 'node:fs'
import { createRequire } from 'node:module'
import { isPlainObject } from './runtime-merge.js'
const require = createRequire(import.meta.url)
export function loadConfig(configPath: string): Record<string, unknown> {
if (!fs.existsSync(configPath)) {
return {}
}
const loaded = require(configPath)
return isPlainObject(loaded) ? loaded : {}
}