|
5 | 5 | */
|
6 | 6 | import * as net from 'net';
|
7 | 7 | import * as path from 'path';
|
| 8 | +import * as tty from 'tty'; |
8 | 9 | import { Terminal, DEFAULT_COLS, DEFAULT_ROWS } from './terminal';
|
9 | 10 | import { IProcessEnv, IPtyForkOptions, IPtyOpenOptions } from './interfaces';
|
10 | 11 | import { ArgvOrCommandLine } from './types';
|
@@ -113,7 +114,7 @@ export class UnixTerminal extends Terminal {
|
113 | 114 | // fork
|
114 | 115 | const term = pty.fork(file, args, parsedEnv, cwd, this._cols, this._rows, uid, gid, (encoding === 'utf8'), helperPath, onexit);
|
115 | 116 |
|
116 |
| - this._socket = new PipeSocket(term.fd); |
| 117 | + this._socket = new tty.ReadStream(term.fd); |
117 | 118 | if (encoding !== null) {
|
118 | 119 | this._socket.setEncoding(encoding);
|
119 | 120 | }
|
@@ -203,13 +204,13 @@ export class UnixTerminal extends Terminal {
|
203 | 204 | // open
|
204 | 205 | const term: IUnixOpenProcess = pty.open(cols, rows);
|
205 | 206 |
|
206 |
| - self._master = new PipeSocket(<number>term.master); |
| 207 | + self._master = new tty.ReadStream(term.master); |
207 | 208 | if (encoding !== null) {
|
208 | 209 | self._master.setEncoding(encoding);
|
209 | 210 | }
|
210 | 211 | self._master.resume();
|
211 | 212 |
|
212 |
| - self._slave = new PipeSocket(term.slave); |
| 213 | + self._slave = new tty.ReadStream(term.slave); |
213 | 214 | if (encoding !== null) {
|
214 | 215 | self._slave.setEncoding(encoding);
|
215 | 216 | }
|
@@ -304,18 +305,3 @@ export class UnixTerminal extends Terminal {
|
304 | 305 | delete env['LINES'];
|
305 | 306 | }
|
306 | 307 | }
|
307 |
| - |
308 |
| -/** |
309 |
| - * Wraps net.Socket to force the handle type "PIPE" by temporarily overwriting |
310 |
| - * tty_wrap.guessHandleType. |
311 |
| - * See: https://github.com/chjj/pty.js/issues/103 |
312 |
| - */ |
313 |
| -class PipeSocket extends net.Socket { |
314 |
| - constructor(fd: number) { |
315 |
| - const pipeWrap = (<any>process).binding('pipe_wrap'); // tslint:disable-line |
316 |
| - // @types/node has fd as string? https://github.com/DefinitelyTyped/DefinitelyTyped/pull/18275 |
317 |
| - const handle = new pipeWrap.Pipe(pipeWrap.constants.SOCKET); |
318 |
| - handle.open(fd); |
319 |
| - super(<any>{ handle }); |
320 |
| - } |
321 |
| -} |
0 commit comments