mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-14 03:20:49 +00:00
31 lines
772 B
TypeScript
31 lines
772 B
TypeScript
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { DiffArtifactStore } from "./store.js";
|
|
|
|
export async function createTempDiffRoot(prefix: string): Promise<{
|
|
rootDir: string;
|
|
cleanup: () => Promise<void>;
|
|
}> {
|
|
const rootDir = await fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
|
return {
|
|
rootDir,
|
|
cleanup: async () => {
|
|
await fs.rm(rootDir, { recursive: true, force: true });
|
|
},
|
|
};
|
|
}
|
|
|
|
export async function createDiffStoreHarness(prefix: string): Promise<{
|
|
rootDir: string;
|
|
store: DiffArtifactStore;
|
|
cleanup: () => Promise<void>;
|
|
}> {
|
|
const { rootDir, cleanup } = await createTempDiffRoot(prefix);
|
|
return {
|
|
rootDir,
|
|
store: new DiffArtifactStore({ rootDir }),
|
|
cleanup,
|
|
};
|
|
}
|