refactor: add hook guards and test helpers
This commit is contained in:
1 parent
32dd052260
commit
28f8b7bafa
12 files changed
+145
-50
No files matched your search
@@ -0,0 +1,17 @@
|
||||
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;
|
||||
}
|
||||
Reference in new issue
Block a user