diff --git a/packages/opencode/src/cli/cmd/github.ts b/packages/opencode/src/cli/cmd/github.ts index 92875e9c93..a58151308c 100644 --- a/packages/opencode/src/cli/cmd/github.ts +++ b/packages/opencode/src/cli/cmd/github.ts @@ -497,18 +497,14 @@ export const GithubRunCommand = cmd({ const gitText = async (args: string[]) => { const result = await git(args, { cwd: Instance.worktree }) if (result.exitCode !== 0) { - throw new Error( - result.stderr.toString().trim() || result.stdout.toString().trim() || `git ${args.join(" ")} failed`, - ) + throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr) } return result.text().trim() } const gitRun = async (args: string[]) => { const result = await git(args, { cwd: Instance.worktree }) if (result.exitCode !== 0) { - throw new Error( - result.stderr.toString().trim() || result.stdout.toString().trim() || `git ${args.join(" ")} failed`, - ) + throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr) } return result } diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.ts index 90c64226db..8d21ac7820 100644 --- a/packages/opencode/src/installation/index.ts +++ b/packages/opencode/src/installation/index.ts @@ -162,7 +162,7 @@ export namespace Installation { } export async function upgrade(method: Method, target: string) { - let result + let result: Awaited> | undefined switch (method) { case "curl": result = await upgradeCurl(target) @@ -183,15 +183,24 @@ export namespace Installation { ...process.env, } if (formula.includes("/")) { - await Process.run(["brew", "tap", "anomalyco/tap"], { env, nothrow: true }) + const tap = await Process.run(["brew", "tap", "anomalyco/tap"], { env, nothrow: true }) + if (tap.code !== 0) { + result = tap + break + } const repo = (await Process.text(["brew", "--repo", "anomalyco/tap"], { env, nothrow: true })).text.trim() - if (repo) await Process.run(["git", "pull", "--ff-only"], { cwd: repo, env, nothrow: true }) - result = await Process.run(["brew", "upgrade", formula], { env, nothrow: true }) - break + if (repo) { + const pull = await Process.run(["git", "pull", "--ff-only"], { cwd: repo, env, nothrow: true }) + if (pull.code !== 0) { + result = pull + break + } + } } result = await Process.run(["brew", "upgrade", formula], { env, nothrow: true }) break } + case "choco": result = await Process.run(["choco", "upgrade", "opencode", `--version=${target}`, "-y"], { nothrow: true }) break