diff --git a/auto-update.ts b/auto-update.ts index fd583ca..841dc73 100644 --- a/auto-update.ts +++ b/auto-update.ts @@ -1,6 +1,7 @@ import * as fs from "fs"; import * as path from "path"; import * as os from "os"; +import { spawn } from "child_process"; import type { PluginInput } from "@opencode-ai/plugin"; const PACKAGE_NAME = "opencode-session-handoff"; @@ -204,16 +205,19 @@ function invalidatePackage(): boolean { async function runBunInstall(): Promise { try { - const proc = Bun.spawn(["bun", "install"], { + const proc = spawn("bun", ["install"], { cwd: getConfigDir(), - stdout: "pipe", - stderr: "pipe", + stdio: "pipe", + }); + + const exitPromise = new Promise((resolve) => { + proc.on("close", (code) => resolve(code)); + proc.on("error", () => resolve(null)); }); const timeoutPromise = new Promise<"timeout">((resolve) => setTimeout(() => resolve("timeout"), BUN_INSTALL_TIMEOUT_MS), ); - const exitPromise = proc.exited.then(() => "completed" as const); const result = await Promise.race([exitPromise, timeoutPromise]); @@ -226,7 +230,7 @@ async function runBunInstall(): Promise { return false; } - return proc.exitCode === 0; + return result === 0; } catch { return false; } diff --git a/package.json b/package.json index df05c66..a0541a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opencode-session-handoff", - "version": "1.1.0", + "version": "1.1.6", "description": "OpenCode plugin for seamless session continuation when context windows fill up", "keywords": [ "context-window",