mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 14:44:32 +00:00
refactor: dedupe core config and runtime helpers
This commit is contained in:
26
src/commands/doctor-config-flow.test-utils.ts
Normal file
26
src/commands/doctor-config-flow.test-utils.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import fs from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
import { withTempHome } from "../../test/helpers/temp-home.js";
|
||||
|
||||
export async function runDoctorConfigWithInput<T>(params: {
|
||||
config: Record<string, unknown>;
|
||||
repair?: boolean;
|
||||
run: (args: {
|
||||
options: { nonInteractive: boolean; repair?: boolean };
|
||||
confirm: () => Promise<boolean>;
|
||||
}) => Promise<T>;
|
||||
}) {
|
||||
return withTempHome(async (home) => {
|
||||
const configDir = path.join(home, ".openclaw");
|
||||
await fs.mkdir(configDir, { recursive: true });
|
||||
await fs.writeFile(
|
||||
path.join(configDir, "openclaw.json"),
|
||||
JSON.stringify(params.config, null, 2),
|
||||
"utf-8",
|
||||
);
|
||||
return params.run({
|
||||
options: { nonInteractive: true, repair: params.repair },
|
||||
confirm: async () => false,
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user