The open source coding agent.
TypeScript
fix: resolve homebrew upgrade requiring multiple runs (#5375) (#10118)
Harsh Sharma56a752092e78
diff --git a/packages/opencode/src/installation/index.ts b/packages/opencode/src/installation/index.tsindex d18c9e31a13..47278bd5628 100644--- a/packages/opencode/src/installation/index.ts+++ b/packages/opencode/src/installation/index.ts@@ -148,6 +148,16 @@ export namespace Installation {breakcase "brew": {const formula = await getBrewFormula()+ if (formula.includes("/")) {+ cmd =+ $`brew tap anomalyco/tap && cd "$(brew --repo anomalyco/tap)" && git pull --ff-only && brew upgrade ${formula}`.env(+ {+ HOMEBREW_NO_AUTO_UPDATE: "1",+ ...process.env,+ },+ )+ break+ }cmd = $`brew upgrade ${formula}`.env({HOMEBREW_NO_AUTO_UPDATE: "1",...process.env,@@ -188,14 +198,19 @@ export namespace Installation {if (detectedMethod === "brew") {const formula = await getBrewFormula()- if (formula === "opencode") {- return fetch("https://formulae.brew.sh/api/formula/opencode.json")- .then((res) => {- if (!res.ok) throw new Error(res.statusText)- return res.json()- })- .then((data: any) => data.versions.stable)+ if (formula.includes("/")) {+ const infoJson = await $`brew info --json=v2 ${formula}`.quiet().text()+ const info = JSON.parse(infoJson)+ const version = info.formulae?.[0]?.versions?.stable+ if (!version) throw new Error(`Could not detect version for tap formula: ${formula}`)+ return version}+ return fetch("https://formulae.brew.sh/api/formula/opencode.json")+ .then((res) => {+ if (!res.ok) throw new Error(res.statusText)+ return res.json()+ })+ .then((data: any) => data.versions.stable)}if (detectedMethod === "npm" || detectedMethod === "bun" || detectedMethod === "pnpm") {