Skip to content
Open
Show file tree
Hide file tree
Changes from 4 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: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "module",
"packageManager": "[email protected]",
"scripts": {
"dev": "bun run --cwd packages/opencode src/index.ts",
"dev": "bun run --cwd packages/opencode --conditions=browser src/index.ts",
"typecheck": "bun turbo typecheck",
"prepare": "husky",
"random": "echo 'Random script'"
Expand Down
25 changes: 25 additions & 0 deletions packages/opencode/bin/run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env node
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