Files
clawdbot/src/test-helpers/workspace.ts
2026-01-18 06:15:24 +00:00

18 lines
495 B
TypeScript

import fs from "node:fs/promises";
import os from "node:os";
import path from "node:path";
export async function makeTempWorkspace(prefix = "clawdbot-workspace-"): Promise<string> {
return fs.mkdtemp(path.join(os.tmpdir(), prefix));
}
export async function writeWorkspaceFile(params: {
dir: string;
name: string;
content: string;
}): Promise<string> {
const filePath = path.join(params.dir, params.name);
await fs.writeFile(filePath, params.content, "utf-8");
return filePath;
}