perf(doctor): cache health config import

This commit is contained in:
Vincent Koc
2026-05-29 21:14:03 +02:00
parent 7c5b55c5ff
commit 1ff95ff3e6

View File

@@ -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,