Skip to content

Commit 24159ee

Browse files
committed
fix(opencode): add process error handlers to oclite entry (#128)
1 parent d6298fe commit 24159ee

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

‎packages/opencode/src/cli/ink/entry.ts‎

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,29 @@ import { Global } from "@/global"
33
import { Log } from "@/util/log"
44
import { Instance } from "@/project/instance"
55
import { InstanceBootstrap } from "@/project/bootstrap"
6+
import { Installation } from "@/installation"
67
import { startInkTUI } from "./index.tsx"
78

89
async function main() {
9-
await Global.init()
10-
await Log.init({ print: false, dev: false, level: "INFO" })
10+
try {
11+
await Global.init()
12+
await Log.init({
13+
print: process.stdout.isTTY,
14+
dev: Installation.isLocal(),
15+
level: "INFO",
16+
})
1117

12-
await Instance.provide({
13-
directory: process.cwd(),
14-
init: InstanceBootstrap,
15-
fn: async () => {
16-
startInkTUI()
17-
},
18-
})
18+
await Instance.provide({
19+
directory: process.cwd(),
20+
init: InstanceBootstrap,
21+
fn: async () => {
22+
await startInkTUI()
23+
},
24+
})
25+
} catch (error) {
26+
console.error("Failed to start oclite:", error)
27+
process.exit(1)
28+
}
1929
}
2030

2131
main()

‎packages/opencode/src/cli/ink/index.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import { render } from "ink"
33
import App from "./App"
44

55
export function startInkTUI() {
6-
render(<App />)
6+
const instance = render(<App />)
7+
return instance.waitUntilExit()
78
}

0 commit comments

Comments
 (0)