refactor(core): type native PTY import explicitly (#45710)

This commit is contained in:
Kit Langton
2026-08-27 22:30:15 -04:00
committed by GitHub
Unverified
parent 43c8690c14
commit d34dd6c14a
+7 -4
View File
@@ -1,14 +1,15 @@
import { createRequire } from "node:module"
import { isSea } from "node:sea"
import type { spawn } from "@lydell/node-pty"
import type { Opts, Proc } from "./pty.js"
export type { Disp, Exit, Opts, Proc } from "./pty.js"
const pty = createRequire(import.meta.url)(
process.env.OPENCODE_NODE_PTY_PATH ?? "@lydell/node-pty",
) as typeof import("@lydell/node-pty")
const pty = createRequire(import.meta.url)(process.env.OPENCODE_NODE_PTY_PATH ?? "@lydell/node-pty") as {
spawn: typeof spawn
}
export function spawn(file: string, args: string[], opts: Opts): Proc {
function spawnPty(file: string, args: string[], opts: Opts): Proc {
const proc = pty.spawn(file, args, process.platform === "win32" && isSea() ? { ...opts, useConptyDll: true } : opts)
return {
pid: proc.pid,
@@ -29,3 +30,5 @@ export function spawn(file: string, args: string[], opts: Opts): Proc {
},
}
}
export { spawnPty as spawn }