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.
@@ -40,7 +40,8 @@ export class ConoutConnection implements IDisposable {
40
40
  private _conoutPipeName: string
41
41
  ) {
42
42
  const workerData: IWorkerData = { conoutPipeName: _conoutPipeName };
43
- this._worker = new Worker(join(__dirname, 'worker/conoutSocketWorker.js'), { workerData });
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:
@@ -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
- this._inSocket = new Socket();
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
  }
@@ -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, as opened file descriptors
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 {