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

Function indexProject

__tests__/rust-glob-use-items.test.ts:18–25  ·  view source on GitHub ↗

Writes `files` into a fresh temp dir and indexes it.

(prefix: string, files: Record<string, string>)

Source from the content-addressed store, hash-verified

16
17/** Writes `files` into a fresh temp dir and indexes it. */
18async function indexProject(prefix: string, files: Record<string, string>): Promise<{ root: string; cg: CodeGraph }> {
19 const root = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
20 for (const [rel, content] of Object.entries(files)) {
21 fs.mkdirSync(path.dirname(path.join(root, rel)), { recursive: true });
22 fs.writeFileSync(path.join(root, rel), content);
23 }
24 return { root, cg: await CodeGraph.init(root, { index: true }) };
25}
26
27/** What `name`, written in `file`, links to, as `file@line` of each target, sorted. */
28const targetsOf = (cg: CodeGraph, file: string, name: string, kinds: string[]): string[] => {

Callers 1

Calls 2

joinMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected