(rootDir: string)
| 82 | } |
| 83 | |
| 84 | async function loadGraph(rootDir: string): Promise<GraphStore> { |
| 85 | if (graphCache.has(rootDir)) return graphCache.get(rootDir)!; |
| 86 | try { |
| 87 | const raw = JSON.parse(await readFile(join(rootDir, CACHE_DIR, GRAPH_FILE), "utf-8")); |
| 88 | const store: GraphStore = { |
| 89 | nodes: raw?.nodes && typeof raw.nodes === "object" ? raw.nodes : {}, |
| 90 | edges: raw?.edges && typeof raw.edges === "object" ? raw.edges : {}, |
| 91 | }; |
| 92 | graphCache.set(rootDir, store); |
| 93 | } catch { |
| 94 | graphCache.set(rootDir, { nodes: {}, edges: {} }); |
| 95 | } |
| 96 | return graphCache.get(rootDir)!; |
| 97 | } |
| 98 | |
| 99 | async function persistGraph(rootDir: string): Promise<void> { |
| 100 | const store = graphCache.get(rootDir); |
no outgoing calls
no test coverage detected