Skip to content

Commit dc06cf1

Browse files
GeneCodeSavvyBryceRyan
authored andcommitted
fix: resolve homebrew upgrade requiring multiple runs (anomalyco#5375) (anomalyco#10118)
1 parent 2ccddcf commit dc06cf1

File tree

1 file changed

+22
-7
lines changed
  • packages/opencode/src/installation

1 file changed

+22
-7
lines changed

packages/opencode/src/installation/index.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ export namespace Installation {
148148
break
149149
case "brew": {
150150
const formula = await getBrewFormula()
151+
if (formula.includes("/")) {
152+
cmd =
153+
$`brew tap anomalyco/tap && cd "$(brew --repo anomalyco/tap)" && git pull --ff-only && brew upgrade ${formula}`.env(
154+
{
155+
HOMEBREW_NO_AUTO_UPDATE: "1",
156+
...process.env,
157+
},
158+
)
159+
break
160+
}
151161
cmd = $`brew upgrade ${formula}`.env({
152162
HOMEBREW_NO_AUTO_UPDATE: "1",
153163
...process.env,
@@ -188,14 +198,19 @@ export namespace Installation {
188198

189199
if (detectedMethod === "brew") {
190200
const formula = await getBrewFormula()
191-
if (formula === "opencode") {
192-
return fetch("https://formulae.brew.sh/api/formula/opencode.json")
193-
.then((res) => {
194-
if (!res.ok) throw new Error(res.statusText)
195-
return res.json()
196-
})
197-
.then((data: any) => data.versions.stable)
201+
if (formula.includes("/")) {
202+
const infoJson = await $`brew info --json=v2 ${formula}`.quiet().text()
203+
const info = JSON.parse(infoJson)
204+
const version = info.formulae?.[0]?.versions?.stable
205+
if (!version) throw new Error(`Could not detect version for tap formula: ${formula}`)
206+
return version
198207
}
208+
return fetch("https://formulae.brew.sh/api/formula/opencode.json")
209+
.then((res) => {
210+
if (!res.ok) throw new Error(res.statusText)
211+
return res.json()
212+
})
213+
.then((data: any) => data.versions.stable)
199214
}
200215

201216
if (detectedMethod === "npm" || detectedMethod === "bun" || detectedMethod === "pnpm") {

0 commit comments

Comments
 (0)