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

Function indexProject

__tests__/rust-use-path-module.test.ts:20–27  ·  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

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