pty.bun.ts 567 B

1234567891011121314151617181920212223242526
  1. import { spawn as create } from "bun-pty"
  2. import type { Opts, Proc } from "./pty"
  3. export type { Disp, Exit, Opts, Proc } from "./pty"
  4. export function spawn(file: string, args: string[], opts: Opts): Proc {
  5. const pty = create(file, args, opts)
  6. return {
  7. pid: pty.pid,
  8. onData(listener) {
  9. return pty.onData(listener)
  10. },
  11. onExit(listener) {
  12. return pty.onExit(listener)
  13. },
  14. write(data) {
  15. pty.write(data)
  16. },
  17. resize(cols, rows) {
  18. pty.resize(cols, rows)
  19. },
  20. kill(signal) {
  21. pty.kill(signal)
  22. },
  23. }
  24. }