mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-04 00:54:04 +00:00
perf(doctor): cache health config import
This commit is contained in:
@@ -6,10 +6,18 @@ import type { RuntimeEnv } from "../runtime.js";
|
||||
const intro = (message: string) => clackIntro(stylePromptTitle(message) ?? message);
|
||||
const outro = (message: string) => clackOutro(stylePromptTitle(message) ?? message);
|
||||
|
||||
type ConfigModule = typeof import("../config/config.js");
|
||||
|
||||
let configModulePromise: Promise<ConfigModule> | undefined;
|
||||
|
||||
function loadConfigModule(): Promise<ConfigModule> {
|
||||
return (configModulePromise ??= import("../config/config.js"));
|
||||
}
|
||||
|
||||
export async function doctorCommand(runtime?: RuntimeEnv, options: DoctorOptions = {}) {
|
||||
const effectiveRuntime = runtime ?? (await import("../runtime.js")).defaultRuntime;
|
||||
if (options.repair === true || options.yes === true || options.generateGatewayToken === true) {
|
||||
const { assertConfigWriteAllowedInCurrentMode } = await import("../config/config.js");
|
||||
const { assertConfigWriteAllowedInCurrentMode } = await loadConfigModule();
|
||||
assertConfigWriteAllowedInCurrentMode();
|
||||
}
|
||||
|
||||
@@ -55,7 +63,7 @@ export async function doctorCommand(runtime?: RuntimeEnv, options: DoctorOptions
|
||||
runtime: effectiveRuntime,
|
||||
prompter,
|
||||
});
|
||||
const { CONFIG_PATH } = await import("../config/config.js");
|
||||
const { CONFIG_PATH } = await loadConfigModule();
|
||||
const ctx = {
|
||||
runtime: effectiveRuntime,
|
||||
options,
|
||||
|
||||
Reference in New Issue
Block a user