mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-27 09:08:37 +00:00
15 lines
321 B
TypeScript
15 lines
321 B
TypeScript
import { createTempHomeEnv } from "../test-utils/temp-home.js";
|
|
|
|
export async function withTempHome<T>(
|
|
prefix: string,
|
|
fn: (home: string) => Promise<T>,
|
|
): Promise<T> {
|
|
const tempHome = await createTempHomeEnv(prefix);
|
|
|
|
try {
|
|
return await fn(tempHome.home);
|
|
} finally {
|
|
await tempHome.restore();
|
|
}
|
|
}
|