node-pty 0.11.0-beta2 → 0.11.0-beta20
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 -1
- package/binding.gyp +66 -29
- package/lib/terminal.js +3 -0
- package/lib/terminal.js.map +1 -1
- package/lib/unixTerminal.js +23 -3
- package/lib/unixTerminal.js.map +1 -1
- package/lib/unixTerminal.test.js +46 -1
- package/lib/unixTerminal.test.js.map +1 -1
- package/lib/windowsConoutConnection.js +2 -1
- package/lib/windowsConoutConnection.js.map +1 -1
- package/package.json +7 -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 +43 -1
- package/src/unixTerminal.ts +17 -4
- package/src/win/conpty.cc +34 -22
- package/src/win/path_util.cc +1 -1
- package/src/windowsConoutConnection.ts +2 -1
- package/typings/node-pty.d.ts +10 -4
package/src/win/conpty.cc
CHANGED
|
@@ -289,6 +289,13 @@ static NAN_METHOD(PtyConnect) {
|
|
|
289
289
|
const v8::Local<v8::Array> envValues = info[3].As<v8::Array>();
|
|
290
290
|
const v8::Local<v8::Function> exitCallback = v8::Local<v8::Function>::Cast(info[4]);
|
|
291
291
|
|
|
292
|
+
// Fetch pty handle from ID and start process
|
|
293
|
+
pty_baton* handle = get_pty_baton(id);
|
|
294
|
+
if (!handle) {
|
|
295
|
+
Nan::ThrowError("Invalid pty handle");
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
|
|
292
299
|
// Prepare command line
|
|
293
300
|
std::unique_ptr<wchar_t[]> mutableCommandline = std::make_unique<wchar_t[]>(cmdline.length() + 1);
|
|
294
301
|
HRESULT hr = StringCchCopyW(mutableCommandline.get(), cmdline.length() + 1, cmdline.c_str());
|
|
@@ -311,11 +318,8 @@ static NAN_METHOD(PtyConnect) {
|
|
|
311
318
|
auto envV = vectorFromString(env);
|
|
312
319
|
LPWSTR envArg = envV.empty() ? nullptr : envV.data();
|
|
313
320
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
BOOL success = ConnectNamedPipe(handle->hIn, nullptr);
|
|
318
|
-
success = ConnectNamedPipe(handle->hOut, nullptr);
|
|
321
|
+
ConnectNamedPipe(handle->hIn, nullptr);
|
|
322
|
+
ConnectNamedPipe(handle->hOut, nullptr);
|
|
319
323
|
|
|
320
324
|
// Attach the pseudoconsole to the client application we're creating
|
|
321
325
|
STARTUPINFOEXW siEx{0};
|
|
@@ -396,15 +400,17 @@ static NAN_METHOD(PtyResize) {
|
|
|
396
400
|
|
|
397
401
|
const pty_baton* handle = get_pty_baton(id);
|
|
398
402
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
PFNRESIZEPSEUDOCONSOLE const pfnResizePseudoConsole = (PFNRESIZEPSEUDOCONSOLE)GetProcAddress((HMODULE)hLibrary, "ResizePseudoConsole");
|
|
404
|
-
if (pfnResizePseudoConsole)
|
|
403
|
+
if (handle != nullptr) {
|
|
404
|
+
HANDLE hLibrary = LoadLibraryExW(L"kernel32.dll", 0, 0);
|
|
405
|
+
bool fLoadedDll = hLibrary != nullptr;
|
|
406
|
+
if (fLoadedDll)
|
|
405
407
|
{
|
|
406
|
-
|
|
407
|
-
pfnResizePseudoConsole
|
|
408
|
+
PFNRESIZEPSEUDOCONSOLE const pfnResizePseudoConsole = (PFNRESIZEPSEUDOCONSOLE)GetProcAddress((HMODULE)hLibrary, "ResizePseudoConsole");
|
|
409
|
+
if (pfnResizePseudoConsole)
|
|
410
|
+
{
|
|
411
|
+
COORD size = {cols, rows};
|
|
412
|
+
pfnResizePseudoConsole(handle->hpc, size);
|
|
413
|
+
}
|
|
408
414
|
}
|
|
409
415
|
}
|
|
410
416
|
|
|
@@ -424,18 +430,24 @@ static NAN_METHOD(PtyKill) {
|
|
|
424
430
|
|
|
425
431
|
const pty_baton* handle = get_pty_baton(id);
|
|
426
432
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
PFNCLOSEPSEUDOCONSOLE const pfnClosePseudoConsole = (PFNCLOSEPSEUDOCONSOLE)GetProcAddress((HMODULE)hLibrary, "ClosePseudoConsole");
|
|
432
|
-
if (pfnClosePseudoConsole)
|
|
433
|
+
if (handle != nullptr) {
|
|
434
|
+
HANDLE hLibrary = LoadLibraryExW(L"kernel32.dll", 0, 0);
|
|
435
|
+
bool fLoadedDll = hLibrary != nullptr;
|
|
436
|
+
if (fLoadedDll)
|
|
433
437
|
{
|
|
434
|
-
pfnClosePseudoConsole(
|
|
438
|
+
PFNCLOSEPSEUDOCONSOLE const pfnClosePseudoConsole = (PFNCLOSEPSEUDOCONSOLE)GetProcAddress((HMODULE)hLibrary, "ClosePseudoConsole");
|
|
439
|
+
if (pfnClosePseudoConsole)
|
|
440
|
+
{
|
|
441
|
+
pfnClosePseudoConsole(handle->hpc);
|
|
442
|
+
}
|
|
435
443
|
}
|
|
436
|
-
}
|
|
437
444
|
|
|
438
|
-
|
|
445
|
+
DisconnectNamedPipe(handle->hIn);
|
|
446
|
+
DisconnectNamedPipe(handle->hOut);
|
|
447
|
+
CloseHandle(handle->hIn);
|
|
448
|
+
CloseHandle(handle->hOut);
|
|
449
|
+
CloseHandle(handle->hShell);
|
|
450
|
+
}
|
|
439
451
|
|
|
440
452
|
return info.GetReturnValue().SetUndefined();
|
|
441
453
|
}
|
package/src/win/path_util.cc
CHANGED
|
@@ -52,7 +52,7 @@ std::wstring get_shell_path(std::wstring filename) {
|
|
|
52
52
|
|
|
53
53
|
const wchar_t *filename_ = filename.c_str();
|
|
54
54
|
|
|
55
|
-
for (
|
|
55
|
+
for (size_t i = 0; i < paths.size(); ++i) {
|
|
56
56
|
std::wstring path = paths[i];
|
|
57
57
|
wchar_t searchPath[MAX_PATH];
|
|
58
58
|
::PathCombineW(searchPath, const_cast<wchar_t*>(path.c_str()), filename_);
|
|
@@ -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/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 {
|
|
@@ -165,7 +171,7 @@ declare module 'node-pty' {
|
|
|
165
171
|
|
|
166
172
|
/**
|
|
167
173
|
* Resizes the dimensions of the pty.
|
|
168
|
-
* @param columns
|
|
174
|
+
* @param columns The number of columns to use.
|
|
169
175
|
* @param rows The number of rows to use.
|
|
170
176
|
*/
|
|
171
177
|
resize(columns: number, rows: number): void;
|