(args: string[], timeoutMs: number)
| 1998 | } |
| 1999 | |
| 2000 | function 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 | |
| 2021 | function sleepMs(milliseconds: number): void { |
| 2022 | if (milliseconds <= 0) return; |
no test coverage detected