MCPcopy Create free account
hub / github.com/Snapchat/Valdi / withTempDir

Function withTempDir

npm_modules/cli/src/utils/tempDir.ts:10–24  ·  view source on GitHub ↗
(receiveTempDir: (tempDir: string) => Promise<T>)

Source from the content-addressed store, hash-verified

8}
9
10export async function withTempDir<T>(receiveTempDir: (tempDir: string) => Promise<T>): Promise<T> {
11 const tempDir = makeTempDir();
12
13 fs.mkdirSync(tempDir);
14
15 try {
16 return await receiveTempDir(tempDir);
17 } finally {
18 try {
19 fs.rmdirSync(tempDir);
20 } catch {
21 // no-op
22 }
23 }
24}

Calls 1

makeTempDirFunction · 0.85

Tested by

no test coverage detected