MCPcopy
hub / github.com/openclaw/clawsweeper / ghOnce

Function ghOnce

src/clawsweeper.ts:2000–2019  ·  view source on GitHub ↗
(args: string[], timeoutMs: number)

Source from the content-addressed store, hash-verified

1998}
1999
2000function ghOnce(args: string[], timeoutMs: number): string {
2001 const command = process.env.GH_BIN ?? "gh";
2002 const resolvedArgs = args[0] === "api" ? args : ["--repo", targetRepo(), ...args];
2003 const result = spawnSync(command, [...ghBinArgs(), ...resolvedArgs], {
2004 cwd: ROOT,
2005 encoding: "utf8",
2006 env: { ...process.env, GIT_OPTIONAL_LOCKS: "0" },
2007 maxBuffer: 8 * 1024 * 1024,
2008 stdio: ["ignore", "pipe", "pipe"],
2009 timeout: timeoutMs,
2010 });
2011 if (result.error) throw result.error;
2012 if (result.status !== 0) {
2013 const stderr = typeof result.stderr === "string" ? result.stderr.trim() : "";
2014 throw new Error(
2015 [`Command failed: gh ${resolvedArgs.join(" ")}`, stderr].filter(Boolean).join("\n"),
2016 );
2017 }
2018 return (result.stdout ?? "").trim();
2019}
2020
2021function sleepMs(milliseconds: number): void {
2022 if (milliseconds <= 0) return;

Callers 1

ghJsonOnceFunction · 0.85

Calls 2

targetRepoFunction · 0.85
ghBinArgsFunction · 0.85

Tested by

no test coverage detected