mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 05:28:16 +00:00
fix: use correct opencode bin path when running in development mode (#483)
This commit is contained in:
parent
ae76a3467a
commit
69920a73d7
1 changed files with 23 additions and 1 deletions
|
@ -100,7 +100,7 @@ export const TuiCommand = cmd({
|
||||||
UI.empty()
|
UI.empty()
|
||||||
UI.println(UI.logo(" "))
|
UI.println(UI.logo(" "))
|
||||||
const result = await Bun.spawn({
|
const result = await Bun.spawn({
|
||||||
cmd: [process.execPath, "auth", "login"],
|
cmd: [...getOpencodeCommand(), "auth", "login"],
|
||||||
cwd: process.cwd(),
|
cwd: process.cwd(),
|
||||||
stdout: "inherit",
|
stdout: "inherit",
|
||||||
stderr: "inherit",
|
stderr: "inherit",
|
||||||
|
@ -112,3 +112,25 @@ export const TuiCommand = cmd({
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the correct command to run opencode CLI
|
||||||
|
* In development: ["bun", "run", "packages/opencode/src/index.ts"]
|
||||||
|
* In production: ["/path/to/opencode"]
|
||||||
|
*/
|
||||||
|
function getOpencodeCommand(): string[] {
|
||||||
|
// Check if OPENCODE_BIN_PATH is set (used by shell wrapper scripts)
|
||||||
|
if (process.env["OPENCODE_BIN_PATH"]) {
|
||||||
|
return [process.env["OPENCODE_BIN_PATH"]]
|
||||||
|
}
|
||||||
|
|
||||||
|
const execPath = process.execPath.toLowerCase()
|
||||||
|
|
||||||
|
if (Installation.isDev()) {
|
||||||
|
// In development, use bun to run the TypeScript entry point
|
||||||
|
return [execPath, "run", process.argv[1]]
|
||||||
|
}
|
||||||
|
|
||||||
|
// In production, use the current executable path
|
||||||
|
return [process.execPath]
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue