MCPcopy Create free account
hub / github.com/arctic-cli/interface / tmpdir

Function tmpdir

packages/arctic/test/fixture/fixture.ts:16–34  ·  view source on GitHub ↗
(options?: TmpDirOptions<T>)

Source from the content-addressed store, hash-verified

14 dispose?: (dir: string) => Promise<T>
15}
16export async function tmpdir<T>(options?: TmpDirOptions<T>) {
17 const dirpath = sanitizePath(path.join(os.tmpdir(), "arctic-test-" + Math.random().toString(36).slice(2)))
18 await fs.mkdir(dirpath, { recursive: true })
19 if (options?.git) {
20 await $`git init`.cwd(dirpath).quiet()
21 await $`git commit --allow-empty -m "root commit ${dirpath}"`.cwd(dirpath).quiet()
22 }
23 const extra = await options?.init?.(dirpath)
24 const realpath = sanitizePath(await fs.realpath(dirpath))
25 const result = {
26 [Symbol.asyncDispose]: async () => {
27 await options?.dispose?.(dirpath)
28 // await fs.rm(dirpath, { recursive: true, force: true })
29 },
30 path: realpath,
31 extra: extra as T,
32 }
33 return result
34}

Callers 15

project.test.tsFile · 0.90
alias.test.tsFile · 0.90
permission.test.tsFile · 0.90
skill.test.tsFile · 0.90
minimax.test.tsFile · 0.90
provider.test.tsFile · 0.90
config.test.tsFile · 0.90
bash.test.tsFile · 0.90
patch.test.tsFile · 0.90
bootstrapFunction · 0.90
headers.test.tsFile · 0.85

Calls 5

sanitizePathFunction · 0.85
quietMethod · 0.80
cwdMethod · 0.65
initMethod · 0.45
disposeMethod · 0.45

Tested by 1

bootstrapFunction · 0.72