MCPcopy Index your code
hub / github.com/ByBrawe/opencode-loop / ensureBranch

Function ensureBranch

src/index.js:687–698  ·  view source on GitHub ↗
(directory, job, client, sessionID)

Source from the content-addressed store, hash-verified

685}
686
687async function runShellCommand(command, cwd, timeoutMs = 120_000) {
688 return await new Promise((resolve) => {
689 const child = spawn(command, [], { cwd, shell: true, windowsHide: true })
690 const stdout = []
691 const stderr = []
692 const timer = setTimeout(() => { try { child.kill("SIGTERM") } catch {} }, timeoutMs)
693 child.stdout?.on("data", (data) => stdout.push(Buffer.from(data)))
694 child.stderr?.on("data", (data) => stderr.push(Buffer.from(data)))
695 child.on("error", (error) => { clearTimeout(timer); resolve({ code: -1, stdout: "", stderr: String(error) }) })
696 child.on("close", (code) => { clearTimeout(timer); resolve({ code: code ?? 0, stdout: Buffer.concat(stdout).toString("utf8"), stderr: Buffer.concat(stderr).toString("utf8") }) })
697 })
698}
699
700async function notifyJob(directory, job, reason) {
701 if (!job.notifyCommand) return

Callers 1

maybeRunDueJobsFunction · 0.85

Calls 4

safeIDFunction · 0.85
runProcessFunction · 0.85
toastFunction · 0.85
appendLoopLogFunction · 0.85

Tested by

no test coverage detected