MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / workspaceRootOf

Function workspaceRootOf

src/resolution/workspace-packages.ts:753–759  ·  view source on GitHub ↗

The nested root (see WorkspacePackages.nestedRoots) `file` is under, the deepest; `''` for the project's own.

(file: string, roots: string[])

Source from the content-addressed store, hash-verified

751
752/** The nested root (see WorkspacePackages.nestedRoots) `file` is under, the deepest; `''` for the project's own. */
753function workspaceRootOf(file: string, roots: string[]): string {
754 let root = '';
755 for (const dir of roots) {
756 if (dir.length > root.length && file.startsWith(dir + '/')) root = dir;
757 }
758 return root;
759}
760
761/** Whether `target`, a project path, lies outside the nested root `file` is under, if it is under one. */
762export function leavesWorkspaceRoot(file: string, target: string, ws: WorkspacePackages | null | undefined): boolean {

Callers 1

leavesWorkspaceRootFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected