mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 02:31:24 +00:00
25 lines
611 B
TypeScript
25 lines
611 B
TypeScript
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach } from "vitest";
|
|
|
|
export function createMemoryCoreTestHarness() {
|
|
const tempDirs: string[] = [];
|
|
|
|
afterEach(async () => {
|
|
await Promise.all(
|
|
tempDirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })),
|
|
);
|
|
});
|
|
|
|
async function createTempWorkspace(prefix: string): Promise<string> {
|
|
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
|
tempDirs.push(workspaceDir);
|
|
return workspaceDir;
|
|
}
|
|
|
|
return {
|
|
createTempWorkspace,
|
|
};
|
|
}
|