MCPcopy
hub / github.com/garrytan/gstack / sourcePageCount

Function sourcePageCount

lib/gbrain-sources.ts:197–219  ·  view source on GitHub ↗
(id: string, env?: NodeJS.ProcessEnv)

Source from the content-addressed store, hash-verified

195 * variant selection.
196 */
197export 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.

Callers 2

runCodeImportFunction · 0.90

Calls 1

parseSourcesListFunction · 0.85

Tested by

no test coverage detected