mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-21 18:26:51 +00:00
* fix(scripts): bound GHSA patch subprocesses Co-authored-by: 唐梓夷0668001293 <tang.ziyi@xydigit.com> * fix(scripts): satisfy GHSA runner control-flow lint --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
23 lines
765 B
JavaScript
23 lines
765 B
JavaScript
import { spawnSync } from "node:child_process";
|
|
|
|
// GHSA patch performs multiple sequential GitHub API reads and writes. Keep enough
|
|
// headroom for GitHub latency while preventing one stalled request from blocking
|
|
// the maintainer command indefinitely.
|
|
export const GHSA_COMMAND_TIMEOUT_MS = 60_000;
|
|
|
|
export function runGhCommand(args, params = {}) {
|
|
const spawnSyncImpl = params.spawnSyncImpl ?? spawnSync;
|
|
const proc = spawnSyncImpl("gh", args, {
|
|
encoding: "utf8",
|
|
killSignal: "SIGKILL",
|
|
timeout: params.timeoutMs ?? GHSA_COMMAND_TIMEOUT_MS,
|
|
});
|
|
if (proc.error) {
|
|
throw proc.error;
|
|
}
|
|
if (proc.status !== 0) {
|
|
throw new Error(proc.stderr.trim() || proc.stdout.trim() || `gh ${args.join(" ")} failed`);
|
|
}
|
|
return proc.stdout;
|
|
}
|