Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/opencode/bin/opencode.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ echo It seems that your package manager failed to install the right version of t
exit /b 1

:execute
rem Remove quotes from resolved path if present
set "resolved=%resolved:"=%"
rem Execute the binary with all arguments in the same console window
rem Use start /b /wait to ensure it runs in the current shell context for all shells
start /b /wait "" "%resolved%" %*
Expand Down
24 changes: 24 additions & 0 deletions packages/opencode/bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { spawn } from "child_process"
import path from "path"
import { fileURLToPath } from "url"

const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)

const command = process.platform === "win32" ? "opencode.cmd" : "opencode"
const commandPath = path.join(__dirname, command)
const args = process.argv.slice(2)

const child = spawn(commandPath, args, {
stdio: "inherit",
shell: process.platform === "win32",
})

child.on("exit", (code) => {
process.exit(code === null ? 1 : code)
})

child.on("error", (err) => {
console.error(`Failed to start subprocess: ${err}`)
process.exit(1)
})
2 changes: 1 addition & 1 deletion packages/opencode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"random": "echo 'Random script updated at $(date)'"
},
"bin": {
"opencode": "./bin/opencode"
"opencode": "./bin/run.js"
},
"exports": {
"./*": "./src/*.ts"
Expand Down
4 changes: 2 additions & 2 deletions packages/script/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { $ } from "bun"

if (process.versions.bun !== "1.3.0") {
throw new Error("This script requires [email protected].0")
if (!process.versions.bun.startsWith("1.3.")) {
throw new Error("This script requires [email protected]+")
}

const CHANNEL = process.env["OPENCODE_CHANNEL"] ?? (await $`git branch --show-current`.text().then((x) => x.trim()))
Expand Down
Loading