node-pty 0.11.0-beta1 → 0.11.0-beta13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/binding.gyp +45 -27
- package/lib/terminal.js +3 -0
- package/lib/terminal.js.map +1 -1
- package/lib/unixTerminal.js +9 -1
- package/lib/unixTerminal.js.map +1 -1
- package/lib/unixTerminal.test.js +31 -0
- package/lib/unixTerminal.test.js.map +1 -1
- package/lib/windowsConoutConnection.js +2 -1
- package/lib/windowsConoutConnection.js.map +1 -1
- package/lib/windowsPtyAgent.js +7 -2
- package/lib/windowsPtyAgent.js.map +1 -1
- package/lib/windowsTerminal.test.js +9 -0
- package/lib/windowsTerminal.test.js.map +1 -1
- package/package.json +4 -4
- package/scripts/post-install.js +1 -0
- package/src/interfaces.ts +3 -4
- package/src/native.d.ts +1 -1
- package/src/terminal.ts +3 -0
- package/src/unix/comms.h +5 -0
- package/src/unix/pty.cc +148 -175
- package/src/unix/spawn-helper.cc +70 -0
- package/src/unixTerminal.test.ts +28 -0
- package/src/unixTerminal.ts +11 -2
- package/src/win/conpty.cc +34 -22
- package/src/win/path_util.cc +1 -1
- package/src/windowsConoutConnection.ts +2 -1
- package/src/windowsPtyAgent.ts +7 -2
- package/src/windowsTerminal.test.ts +10 -0
- package/typings/node-pty.d.ts +9 -3
|
@@ -40,7 +40,8 @@ export class ConoutConnection implements IDisposable {
|
|
|
40
40
|
private _conoutPipeName: string
|
|
41
41
|
) {
|
|
42
42
|
const workerData: IWorkerData = { conoutPipeName: _conoutPipeName };
|
|
43
|
-
|
|
43
|
+
const scriptPath = __dirname.replace('node_modules.asar', 'node_modules.asar.unpacked');
|
|
44
|
+
this._worker = new Worker(join(scriptPath, 'worker/conoutSocketWorker.js'), { workerData });
|
|
44
45
|
this._worker.on('message', (message: ConoutWorkerMessage) => {
|
|
45
46
|
switch (message) {
|
|
46
47
|
case ConoutWorkerMessage.READY:
|
package/src/windowsPtyAgent.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright (c) 2018, Microsoft Corporation (MIT License).
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
import * as fs from 'fs';
|
|
7
8
|
import * as os from 'os';
|
|
8
9
|
import * as path from 'path';
|
|
9
10
|
import { Socket } from 'net';
|
|
@@ -126,9 +127,13 @@ export class WindowsPtyAgent {
|
|
|
126
127
|
this._outSocket.emit('ready_datapipe');
|
|
127
128
|
});
|
|
128
129
|
|
|
129
|
-
|
|
130
|
+
const inSocketFD = fs.openSync(term.conin, 'w');
|
|
131
|
+
this._inSocket = new Socket({
|
|
132
|
+
fd: inSocketFD,
|
|
133
|
+
readable: false,
|
|
134
|
+
writable: true
|
|
135
|
+
});
|
|
130
136
|
this._inSocket.setEncoding('utf8');
|
|
131
|
-
this._inSocket.connect(term.conin);
|
|
132
137
|
|
|
133
138
|
if (this._useConpty) {
|
|
134
139
|
const connect = (this._ptyNative as IConptyNative).connect(this._pty, commandLine, cwd, env, c => this._$onProcessExit(c));
|
|
@@ -201,5 +201,15 @@ if (process.platform === 'win32') {
|
|
|
201
201
|
});
|
|
202
202
|
});
|
|
203
203
|
});
|
|
204
|
+
|
|
205
|
+
describe('winpty', () => {
|
|
206
|
+
it('should accept input', (done) => {
|
|
207
|
+
const term = new WindowsTerminal('cmd.exe', '', { useConpty: false });
|
|
208
|
+
term.write('exit\r');
|
|
209
|
+
term.on('exit', () => {
|
|
210
|
+
done();
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
});
|
|
204
214
|
});
|
|
205
215
|
}
|
package/typings/node-pty.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ declare module 'node-pty' {
|
|
|
42
42
|
/**
|
|
43
43
|
* Environment to be set for the child program.
|
|
44
44
|
*/
|
|
45
|
-
env?: { [key: string]: string };
|
|
45
|
+
env?: { [key: string]: string | undefined };
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* String encoding of the underlying pty.
|
|
@@ -78,11 +78,17 @@ declare module 'node-pty' {
|
|
|
78
78
|
|
|
79
79
|
export interface IPtyForkOptions extends IBasePtyForkOptions {
|
|
80
80
|
/**
|
|
81
|
-
* Security warning: use this option with great caution
|
|
82
|
-
* with higher privileges might leak to the child program.
|
|
81
|
+
* Security warning: use this option with great caution unless `closeFDs` is also set,
|
|
82
|
+
* as opened file descriptors with higher privileges might leak to the child program.
|
|
83
83
|
*/
|
|
84
84
|
uid?: number;
|
|
85
85
|
gid?: number;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Close all open file after spawning the child process (UNIX only).
|
|
89
|
+
* Carries a performance penalty on Linux.
|
|
90
|
+
*/
|
|
91
|
+
closeFDs?: boolean;
|
|
86
92
|
}
|
|
87
93
|
|
|
88
94
|
export interface IWindowsPtyForkOptions extends IBasePtyForkOptions {
|