(directory, job, client, sessionID)
| 685 | } |
| 686 | |
| 687 | async 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 | |
| 700 | async function notifyJob(directory, job, reason) { |
| 701 | if (!job.notifyCommand) return |
no test coverage detected