Writes `files` into a fresh temp dir and indexes it.
(prefix: string, files: Record<string, string>)
| 18 | |
| 19 | /** Writes `files` into a fresh temp dir and indexes it. */ |
| 20 | async 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. */ |
| 30 | const targetsOf = (cg: CodeGraph, file: string, name: string, kinds: string[]): string[] => { |
no test coverage detected