fix(tui): harden the interactive terminal experience
This commit is contained in:
1 parent
5feb21543c
commit
4f12e15237
8 files changed
+1454
-216
No files matched your search
@@ -18,4 +18,23 @@ const options: AppOptions = {
|
||||
}
|
||||
|
||||
const app = await NanobotTui.create(options)
|
||||
|
||||
const shutdown = (code = 0) => {
|
||||
app.stop()
|
||||
process.exitCode = code
|
||||
}
|
||||
|
||||
for (const signal of ["SIGHUP", "SIGINT", "SIGTERM"] as const) {
|
||||
process.once(signal, () => shutdown())
|
||||
}
|
||||
process.once("exit", () => app.stop())
|
||||
process.once("uncaughtException", (error) => {
|
||||
shutdown(1)
|
||||
process.stderr.write(`${error instanceof Error ? error.stack || error.message : String(error)}\n`)
|
||||
})
|
||||
process.once("unhandledRejection", (error) => {
|
||||
shutdown(1)
|
||||
process.stderr.write(`${error instanceof Error ? error.stack || error.message : String(error)}\n`)
|
||||
})
|
||||
|
||||
app.start()
|
||||
Reference in new issue
Block a user