mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 17:41:36 +00:00
refactor: eliminate remaining duplicate blocks across draft streams and tests
This commit is contained in:
18
src/test-utils/tracked-temp-dirs.ts
Normal file
18
src/test-utils/tracked-temp-dirs.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
export function createTrackedTempDirs() {
|
||||
const dirs: string[] = [];
|
||||
|
||||
return {
|
||||
async make(prefix: string): Promise<string> {
|
||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), prefix));
|
||||
dirs.push(dir);
|
||||
return dir;
|
||||
},
|
||||
async cleanup(): Promise<void> {
|
||||
await Promise.all(dirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true })));
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user