fix(opencode): address migration review feedback

This commit is contained in:
Dax Raad
2026-03-06 01:25:04 -05:00
parent f1c7d4cefb
commit 3b2e3afebd
2 changed files with 16 additions and 11 deletions

View File

@@ -497,18 +497,14 @@ export const GithubRunCommand = cmd({
const gitText = async (args: string[]) => { const gitText = async (args: string[]) => {
const result = await git(args, { cwd: Instance.worktree }) const result = await git(args, { cwd: Instance.worktree })
if (result.exitCode !== 0) { if (result.exitCode !== 0) {
throw new Error( throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr)
result.stderr.toString().trim() || result.stdout.toString().trim() || `git ${args.join(" ")} failed`,
)
} }
return result.text().trim() return result.text().trim()
} }
const gitRun = async (args: string[]) => { const gitRun = async (args: string[]) => {
const result = await git(args, { cwd: Instance.worktree }) const result = await git(args, { cwd: Instance.worktree })
if (result.exitCode !== 0) { if (result.exitCode !== 0) {
throw new Error( throw new Process.RunFailedError(["git", ...args], result.exitCode, result.stdout, result.stderr)
result.stderr.toString().trim() || result.stdout.toString().trim() || `git ${args.join(" ")} failed`,
)
} }
return result return result
} }

View File

@@ -162,7 +162,7 @@ export namespace Installation {
} }
export async function upgrade(method: Method, target: string) { export async function upgrade(method: Method, target: string) {
let result let result: Awaited<ReturnType<typeof upgradeCurl>> | undefined
switch (method) { switch (method) {
case "curl": case "curl":
result = await upgradeCurl(target) result = await upgradeCurl(target)
@@ -183,15 +183,24 @@ export namespace Installation {
...process.env, ...process.env,
} }
if (formula.includes("/")) { 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() 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 }) if (repo) {
result = await Process.run(["brew", "upgrade", formula], { env, nothrow: true }) const pull = await Process.run(["git", "pull", "--ff-only"], { cwd: repo, env, nothrow: true })
if (pull.code !== 0) {
result = pull
break break
} }
}
}
result = await Process.run(["brew", "upgrade", formula], { env, nothrow: true }) result = await Process.run(["brew", "upgrade", formula], { env, nothrow: true })
break break
} }
case "choco": case "choco":
result = await Process.run(["choco", "upgrade", "opencode", `--version=${target}`, "-y"], { nothrow: true }) result = await Process.run(["choco", "upgrade", "opencode", `--version=${target}`, "-y"], { nothrow: true })
break break