( projectPath: string, optsOrExtras?: Set<string> | RebuildGraphOptions, )
| 152 | * Set) or a `RebuildGraphOptions` object. |
| 153 | */ |
| 154 | export async function rebuildGraph( |
| 155 | projectPath: string, |
| 156 | optsOrExtras?: Set<string> | RebuildGraphOptions, |
| 157 | ): Promise<CodeGraph> { |
| 158 | const resolved = path.resolve(projectPath); |
| 159 | const opts: RebuildGraphOptions = |
| 160 | optsOrExtras instanceof Set ? { extraExtensions: optsOrExtras } : (optsOrExtras ?? {}); |
| 161 | |
| 162 | // Concurrency guard: if already building, return the existing promise |
| 163 | const existing = graphBuildPromises.get(resolved); |
| 164 | if (existing) { |
| 165 | logger.info("Graph build already in progress, joining existing build", { projectPath: resolved }); |
| 166 | return existing; |
| 167 | } |
| 168 | |
| 169 | // Start tracked build |
| 170 | const promise = doRebuildGraph(resolved, opts); |
| 171 | graphBuildPromises.set(resolved, promise); |
| 172 | |
| 173 | try { |
| 174 | const graph = await promise; |
| 175 | return graph; |
| 176 | } finally { |
| 177 | graphBuildPromises.delete(resolved); |
| 178 | } |
| 179 | } |
| 180 | |
| 181 | /** Internal: performs the actual graph rebuild with progress tracking */ |
| 182 | async function doRebuildGraph( |
no test coverage detected