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

Function NearestRoot

packages/arctic/src/lsp/server.ts:23–45  ·  view source on GitHub ↗
(includePatterns: string[], excludePatterns?: string[])

Source from the content-addressed store, hash-verified

21 type RootFunction = (file: string) => Promise<string | undefined>
22
23 const NearestRoot = (includePatterns: string[], excludePatterns?: string[]): RootFunction => {
24 return async (file) => {
25 if (excludePatterns) {
26 const excludedFiles = Filesystem.up({
27 targets: excludePatterns,
28 start: path.dirname(file),
29 stop: Instance.directory,
30 })
31 const excluded = await excludedFiles.next()
32 await excludedFiles.return()
33 if (excluded.value) return undefined
34 }
35 const files = Filesystem.up({
36 targets: includePatterns,
37 start: path.dirname(file),
38 stop: Instance.directory,
39 })
40 const first = await files.next()
41 await files.return()
42 if (!first.value) return Instance.directory
43 return path.dirname(first.value)
44 }
45 }
46
47 export interface Info {
48 id: string

Callers 1

server.tsFile · 0.85

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected