{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,aAAa;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,GAAE,aAAkB,GAAG,OAAO,CAAC,aAAa,CAAC,CA8BjG","sourcesContent":["import { spawn } from \"node:child_process\";\nimport { existsSync } from \"node:fs\";\nimport type { ProjectTask } from \"./tasks.js\";\n\nexport interface VerifyOutcome {\n\tpassed: boolean;\n\tlog: string;\n}\n\nexport interface VerifyOptions {\n\ttimeoutMs?: number;\n}\n\nexport function verifyTask(task: ProjectTask, options: VerifyOptions = {}): Promise<VerifyOutcome> {\n\tif (!existsSync(task.verifyPath)) {\n\t\treturn Promise.resolve({ passed: false, log: `verify script missing: ${task.verifyPath}` });\n\t}\n\treturn new Promise((resolve) => {\n\t\tconst child = spawn(task.verifyPath, [], { cwd: task.workdir ?? task.dir });\n\t\tlet log = \"\";\n\t\tlet settled = false;\n\t\tconst finish = (outcome: VerifyOutcome): void => {\n\t\t\tif (!settled) {\n\t\t\t\tsettled = true;\n\t\t\t\tclearTimeout(timeout);\n\t\t\t\tresolve(outcome);\n\t\t\t}\n\t\t};\n\t\tconst collect = (chunk: Buffer): void => {\n\t\t\tlog += chunk.toString(\"utf8\");\n\t\t};\n\t\tconst timeout = setTimeout(() => {\n\t\t\tchild.kill(\"SIGKILL\");\n\t\t\tfinish({\n\t\t\t\tpassed: false,\n\t\t\t\tlog: `${log}\\nverify script timed out after ${options.timeoutMs ?? 300000}ms`.trim(),\n\t\t\t});\n\t\t}, options.timeoutMs ?? 300000);\n\t\tchild.stdout.on(\"data\", collect);\n\t\tchild.stderr.on(\"data\", collect);\n\t\tchild.on(\"error\", (error) => finish({ passed: false, log: `${log}\\n${error.message}`.trim() }));\n\t\tchild.on(\"exit\", (code) => finish({ passed: code === 0, log: log.trim() }));\n\t});\n}\n"]}