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

Function provide

packages/arctic/src/project/instance.ts:18–40  ·  view source on GitHub ↗
(input: { directory: string; init?: () => Promise<any>; fn: () => R })

Source from the content-addressed store, hash-verified

16
17export const Instance = {
18 async provide<R>(input: { directory: string; init?: () => Promise<any>; fn: () => R }): Promise<R> {
19 let existing = cache.get(input.directory)
20 if (!existing) {
21 Log.Default.info("creating instance", { directory: input.directory })
22 existing = iife(async () => {
23 const project = await Project.fromDirectory(input.directory)
24 const ctx = {
25 directory: input.directory,
26 worktree: project.worktree,
27 project,
28 }
29 await context.provide(ctx, async () => {
30 await input.init?.()
31 })
32 return ctx
33 })
34 cache.set(input.directory, existing)
35 }
36 const ctx = await existing
37 return context.provide(ctx, async () => {
38 return input.fn()
39 })
40 },
41 async provideContext<R>(
42 ctx: { directory: string; worktree: string; project: Project.Info; eventDirectory?: string },
43 fn: () => R,

Callers

nothing calls this directly

Calls 4

iifeFunction · 0.90
getMethod · 0.45
initMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected