UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

43 lines • 1.79 kB
import { spawn, spawnSync } from "node:child_process"; import { signalSpawnedChild } from "../../utils/child-signal.js"; export function checkGhAuth() { const result = spawnSync("gh", ["auth", "status"], { encoding: "utf-8" }); if (result.error !== undefined) return "missing"; return result.status === 0 ? "ok" : "logged-out"; } /** Creates a secret gist from `html` piped through stdin, so the export never lands on disk. */ export function uploadSecretGist(html, fileName, signal) { return new Promise((resolve) => { if (signal.aborted) { resolve({ code: null, stdout: "", stderr: "", aborted: true }); return; } const child = spawn("gh", ["gist", "create", "--filename", fileName, "-"], { stdio: ["pipe", "pipe", "pipe"], // senpi#3965: gh is a console-subsystem exe on Windows. windowsHide: true, }); let stdout = ""; let stderr = ""; const onAbort = () => signalSpawnedChild(child); signal.addEventListener("abort", onAbort, { once: true }); child.stdout.on("data", (data) => { stdout += data.toString(); }); child.stderr.on("data", (data) => { stderr += data.toString(); }); child.on("error", (error) => { signal.removeEventListener("abort", onAbort); resolve({ code: null, stdout, stderr: error.message, aborted: signal.aborted }); }); child.on("close", (code) => { signal.removeEventListener("abort", onAbort); resolve({ code, stdout, stderr, aborted: signal.aborted }); }); child.stdin.on("error", () => { }); child.stdin.end(html); }); } //# sourceMappingURL=share-gh.js.map