(id: string, env?: NodeJS.ProcessEnv)
| 195 | * variant selection. |
| 196 | */ |
| 197 | export function sourcePageCount(id: string, env?: NodeJS.ProcessEnv): number | null { |
| 198 | let stdout: string; |
| 199 | try { |
| 200 | stdout = execFileSync("gbrain", ["sources", "list", "--json"], { |
| 201 | encoding: "utf-8", |
| 202 | timeout: 30_000, |
| 203 | stdio: ["ignore", "pipe", "pipe"], |
| 204 | env, |
| 205 | shell: NEEDS_SHELL_ON_WINDOWS, // #1731: gbrain is a .cmd shim on Windows |
| 206 | }); |
| 207 | } catch { |
| 208 | return null; |
| 209 | } |
| 210 | |
| 211 | try { |
| 212 | const match = parseSourcesList(JSON.parse(stdout)).find((s) => s.id === id); |
| 213 | if (!match) return null; |
| 214 | if (typeof match.page_count !== "number") return null; |
| 215 | return match.page_count; |
| 216 | } catch { |
| 217 | return null; |
| 218 | } |
| 219 | } |
| 220 | |
| 221 | /** |
| 222 | * Whether a source's call graph has been built. |
no test coverage detected