@theia/process 1.17.0-next.ff9e0507 → 1.18.0-next.04e2816d
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/lib/common/process-common-module.js +3 -3
- package/lib/common/process-common-module.js.map +1 -1
- package/lib/common/shell-command-builder.js +54 -129
- package/lib/common/shell-command-builder.js.map +1 -1
- package/lib/common/shell-command-builder.slow-spec.js +162 -291
- package/lib/common/shell-command-builder.slow-spec.js.map +1 -1
- package/lib/common/shell-quoting.js +22 -22
- package/lib/common/shell-quoting.js.map +1 -1
- package/lib/common/shell-quoting.spec.js +34 -84
- package/lib/common/shell-quoting.spec.js.map +1 -1
- package/lib/node/dev-null-stream.js +10 -27
- package/lib/node/dev-null-stream.js.map +1 -1
- package/lib/node/multi-ring-buffer.js +104 -195
- package/lib/node/multi-ring-buffer.js.map +1 -1
- package/lib/node/multi-ring-buffer.spec.js +220 -468
- package/lib/node/multi-ring-buffer.spec.js.map +1 -1
- package/lib/node/process-backend-module.js +25 -31
- package/lib/node/process-backend-module.js.map +1 -1
- package/lib/node/process-manager.js +37 -65
- package/lib/node/process-manager.js.map +1 -1
- package/lib/node/process.js +68 -131
- package/lib/node/process.js.map +1 -1
- package/lib/node/pseudo-pty.js +8 -9
- package/lib/node/pseudo-pty.js.map +1 -1
- package/lib/node/raw-process.js +60 -92
- package/lib/node/raw-process.js.map +1 -1
- package/lib/node/raw-process.spec.js +114 -238
- package/lib/node/raw-process.spec.js.map +1 -1
- package/lib/node/task-terminal-process.js +13 -29
- package/lib/node/task-terminal-process.js.map +1 -1
- package/lib/node/terminal-process.js +75 -103
- package/lib/node/terminal-process.js.map +1 -1
- package/lib/node/terminal-process.spec.js +55 -132
- package/lib/node/terminal-process.spec.js.map +1 -1
- package/lib/node/test/process-test-container.js +4 -4
- package/lib/node/test/process-test-container.js.map +1 -1
- package/lib/node/utils.js +12 -45
- package/lib/node/utils.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw-process.spec.js","sourceRoot":"","sources":["../../src/node/raw-process.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"raw-process.spec.js","sourceRoot":"","sources":["../../src/node/raw-process.spec.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;;;;;;kFAckF;AAClF,6BAA6B;AAC7B,mCAAmC;AACnC,iCAAiC;AACjC,0EAA2E;AAC3E,+CAAkD;AAClD,6BAA6B;AAC7B,yBAAyB;AACzB,6BAA6B;AAC7B,sCAAwC;AAGxC,wEAAwE;AACxE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;AAE3B;;GAEG;AAEH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;AAC3B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,0CAA0C,CAAC,CAAC;AAExF,QAAQ,CAAC,YAAY,EAAE;IAEnB,IAAI,CAAC,OAAO,CAAC,KAAM,CAAC,CAAC;IAErB,IAAI,iBAAoC,CAAC;IAEzC,UAAU,CAAC,GAAG,EAAE;QACZ,iBAAiB,GAAG,mDAA0B,EAAE,CAAC,GAAG,CAAoB,+BAAiB,CAAC,CAAC;IAC/F,CAAC,CAAC,CAAC;IAEH,KAAK,CAAC,GAAG,EAAE;QACP,KAAK,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,KAAK;QACvC,MAAM,KAAK,GAAG,MAAM,IAAI,OAAO,CAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACnE,MAAM,IAAI,GAAG,iBAAiB,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC;YAC7D,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACrB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,MAAM,CAA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|
14
14
|
*
|
|
15
15
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
16
|
********************************************************************************/
|
|
17
|
-
var __extends = (this && this.__extends) || (function () {
|
|
18
|
-
var extendStatics = function (d, b) {
|
|
19
|
-
extendStatics = Object.setPrototypeOf ||
|
|
20
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
21
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
22
|
-
return extendStatics(d, b);
|
|
23
|
-
};
|
|
24
|
-
return function (d, b) {
|
|
25
|
-
extendStatics(d, b);
|
|
26
|
-
function __() { this.constructor = d; }
|
|
27
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
28
|
-
};
|
|
29
|
-
})();
|
|
30
17
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
31
18
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
32
19
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -35,18 +22,16 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
35
22
|
};
|
|
36
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
24
|
exports.TaskTerminalProcess = exports.TaskTerminalProcessFactory = void 0;
|
|
38
|
-
|
|
39
|
-
|
|
25
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
26
|
+
const terminal_process_1 = require("./terminal-process");
|
|
40
27
|
exports.TaskTerminalProcessFactory = Symbol('TaskTerminalProcessFactory');
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_this.attachmentAttempted = false;
|
|
47
|
-
return _this;
|
|
28
|
+
let TaskTerminalProcess = class TaskTerminalProcess extends terminal_process_1.TerminalProcess {
|
|
29
|
+
constructor() {
|
|
30
|
+
super(...arguments);
|
|
31
|
+
this.exited = false;
|
|
32
|
+
this.attachmentAttempted = false;
|
|
48
33
|
}
|
|
49
|
-
|
|
34
|
+
onTerminalExit(code, signal) {
|
|
50
35
|
this.emitOnExit(code, signal);
|
|
51
36
|
this.exited = true;
|
|
52
37
|
// Unregister process only if task terminal already attached (or failed attach),
|
|
@@ -54,11 +39,10 @@ var TaskTerminalProcess = /** @class */ (function (_super) {
|
|
|
54
39
|
if (this.attachmentAttempted) {
|
|
55
40
|
this.unregisterProcess();
|
|
56
41
|
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}(terminal_process_1.TerminalProcess));
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
TaskTerminalProcess = __decorate([
|
|
45
|
+
inversify_1.injectable()
|
|
46
|
+
], TaskTerminalProcess);
|
|
63
47
|
exports.TaskTerminalProcess = TaskTerminalProcess;
|
|
64
48
|
//# sourceMappingURL=task-terminal-process.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task-terminal-process.js","sourceRoot":"","sources":["../../src/node/task-terminal-process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF
|
|
1
|
+
{"version":3,"file":"task-terminal-process.js","sourceRoot":"","sources":["../../src/node/task-terminal-process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;AAElF,4DAA0D;AAC1D,yDAA6E;AAEhE,QAAA,0BAA0B,GAAG,MAAM,CAAC,4BAA4B,CAAC,CAAC;AAM/E,IAAa,mBAAmB,GAAhC,MAAa,mBAAoB,SAAQ,kCAAe;IAAxD;;QAEW,WAAM,GAAG,KAAK,CAAC;QACf,wBAAmB,GAAG,KAAK,CAAC;IAYvC,CAAC;IAVa,cAAc,CAAC,IAAwB,EAAE,MAA0B;QACzE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,gFAAgF;QAChF,2DAA2D;QAC3D,IAAI,IAAI,CAAC,mBAAmB,EAAE;YAC1B,IAAI,CAAC,iBAAiB,EAAE,CAAC;SAC5B;IACL,CAAC;CAEJ,CAAA;AAfY,mBAAmB;IAD/B,sBAAU,EAAE;GACA,mBAAmB,CAe/B;AAfY,kDAAmB"}
|
|
@@ -14,19 +14,6 @@
|
|
|
14
14
|
*
|
|
15
15
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
16
16
|
********************************************************************************/
|
|
17
|
-
var __extends = (this && this.__extends) || (function () {
|
|
18
|
-
var extendStatics = function (d, b) {
|
|
19
|
-
extendStatics = Object.setPrototypeOf ||
|
|
20
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
21
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
22
|
-
return extendStatics(d, b);
|
|
23
|
-
};
|
|
24
|
-
return function (d, b) {
|
|
25
|
-
extendStatics(d, b);
|
|
26
|
-
function __() { this.constructor = d; }
|
|
27
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
28
|
-
};
|
|
29
|
-
})();
|
|
30
17
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
31
18
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
32
19
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -41,17 +28,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
41
28
|
};
|
|
42
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
30
|
exports.TerminalProcess = exports.TerminalProcessFactory = exports.TerminalProcessOptions = void 0;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
31
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
32
|
+
const core_1 = require("@theia/core");
|
|
33
|
+
const common_1 = require("@theia/core/lib/common");
|
|
34
|
+
const process_1 = require("./process");
|
|
35
|
+
const process_manager_1 = require("./process-manager");
|
|
36
|
+
const node_pty_1 = require("@theia/node-pty");
|
|
37
|
+
const multi_ring_buffer_1 = require("./multi-ring-buffer");
|
|
38
|
+
const dev_null_stream_1 = require("./dev-null-stream");
|
|
39
|
+
const utils_1 = require("./utils");
|
|
40
|
+
const pseudo_pty_1 = require("./pseudo-pty");
|
|
41
|
+
const stream_1 = require("stream");
|
|
55
42
|
exports.TerminalProcessOptions = Symbol('TerminalProcessOptions');
|
|
56
43
|
exports.TerminalProcessFactory = Symbol('TerminalProcessFactory');
|
|
57
44
|
/**
|
|
@@ -59,40 +46,39 @@ exports.TerminalProcessFactory = Symbol('TerminalProcessFactory');
|
|
|
59
46
|
*
|
|
60
47
|
* Note: a PTY is not a shell process (bash/pwsh/cmd...)
|
|
61
48
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
function TerminalProcess(// eslint-disable-next-line @typescript-eslint/indent
|
|
49
|
+
let TerminalProcess = class TerminalProcess extends process_1.Process {
|
|
50
|
+
constructor(// eslint-disable-next-line @typescript-eslint/indent
|
|
65
51
|
options, processManager, ringBuffer, logger) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
52
|
+
super(processManager, logger, process_1.ProcessType.Terminal, options);
|
|
53
|
+
this.options = options;
|
|
54
|
+
this.ringBuffer = ringBuffer;
|
|
55
|
+
this.outputStream = this.createOutputStream();
|
|
56
|
+
this.errorStream = new dev_null_stream_1.DevNullStream({ autoDestroy: true });
|
|
71
57
|
if (options.isPseudo) {
|
|
72
58
|
// do not need to spawn a process, new a pseudo pty instead
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
return
|
|
59
|
+
this.terminal = new pseudo_pty_1.PseudoPty();
|
|
60
|
+
this.inputStream = new dev_null_stream_1.DevNullStream({ autoDestroy: true });
|
|
61
|
+
return;
|
|
76
62
|
}
|
|
77
|
-
if (
|
|
63
|
+
if (this.isForkOptions(this.options)) {
|
|
78
64
|
throw new Error('terminal processes cannot be forked as of today');
|
|
79
65
|
}
|
|
80
|
-
|
|
66
|
+
this.logger.debug('Starting terminal process', JSON.stringify(options, undefined, 2));
|
|
81
67
|
try {
|
|
82
|
-
|
|
83
|
-
|
|
68
|
+
this.terminal = node_pty_1.spawn(options.command, (core_1.isWindows && options.commandLine) || options.args || [], options.options || {});
|
|
69
|
+
this.terminal.on('exec', (reason) => {
|
|
84
70
|
if (reason === undefined) {
|
|
85
|
-
|
|
71
|
+
this.emitOnStarted();
|
|
86
72
|
}
|
|
87
73
|
else {
|
|
88
|
-
|
|
74
|
+
const error = new Error(reason);
|
|
89
75
|
error.code = reason;
|
|
90
|
-
|
|
76
|
+
this.emitOnError(error);
|
|
91
77
|
}
|
|
92
78
|
});
|
|
93
79
|
// node-pty actually wait for the underlying streams to be closed before emitting exit.
|
|
94
80
|
// We should emulate the `exit` and `close` sequence.
|
|
95
|
-
|
|
81
|
+
this.terminal.on('exit', (code, signal) => {
|
|
96
82
|
// Make sure to only pass either code or signal as !undefined, not
|
|
97
83
|
// both.
|
|
98
84
|
//
|
|
@@ -102,35 +88,35 @@ var TerminalProcess = /** @class */ (function (_super) {
|
|
|
102
88
|
// signal parameter will hold the signal number and code should
|
|
103
89
|
// be ignored.
|
|
104
90
|
if (signal === undefined || signal === 0) {
|
|
105
|
-
|
|
91
|
+
this.onTerminalExit(code, undefined);
|
|
106
92
|
}
|
|
107
93
|
else {
|
|
108
|
-
|
|
94
|
+
this.onTerminalExit(undefined, utils_1.signame(signal));
|
|
109
95
|
}
|
|
110
|
-
process.nextTick(
|
|
96
|
+
process.nextTick(() => {
|
|
111
97
|
if (signal === undefined || signal === 0) {
|
|
112
|
-
|
|
98
|
+
this.emitOnClose(code, undefined);
|
|
113
99
|
}
|
|
114
100
|
else {
|
|
115
|
-
|
|
101
|
+
this.emitOnClose(undefined, utils_1.signame(signal));
|
|
116
102
|
}
|
|
117
103
|
});
|
|
118
104
|
});
|
|
119
|
-
|
|
105
|
+
this.terminal.on('data', (data) => {
|
|
120
106
|
ringBuffer.enq(data);
|
|
121
107
|
});
|
|
122
|
-
|
|
123
|
-
write:
|
|
124
|
-
|
|
108
|
+
this.inputStream = new stream_1.Writable({
|
|
109
|
+
write: (chunk) => {
|
|
110
|
+
this.write(chunk);
|
|
125
111
|
},
|
|
126
112
|
});
|
|
127
113
|
}
|
|
128
114
|
catch (error) {
|
|
129
|
-
|
|
115
|
+
this.inputStream = new dev_null_stream_1.DevNullStream({ autoDestroy: true });
|
|
130
116
|
// Normalize the error to make it as close as possible as what
|
|
131
117
|
// node's child_process.spawn would generate in the same
|
|
132
118
|
// situation.
|
|
133
|
-
|
|
119
|
+
const message = error.message;
|
|
134
120
|
if (message.startsWith('File not found: ')) {
|
|
135
121
|
error.errno = 'ENOENT';
|
|
136
122
|
error.code = 'ENOENT';
|
|
@@ -138,70 +124,56 @@ var TerminalProcess = /** @class */ (function (_super) {
|
|
|
138
124
|
}
|
|
139
125
|
// node-pty throws exceptions on Windows.
|
|
140
126
|
// Call the client error handler, but first give them a chance to register it.
|
|
141
|
-
|
|
127
|
+
this.emitOnErrorAsync(error);
|
|
142
128
|
}
|
|
143
|
-
return _this;
|
|
144
129
|
}
|
|
145
|
-
|
|
130
|
+
createOutputStream() {
|
|
146
131
|
return this.ringBuffer.getStream();
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
},
|
|
160
|
-
enumerable: false,
|
|
161
|
-
configurable: true
|
|
162
|
-
});
|
|
163
|
-
Object.defineProperty(TerminalProcess.prototype, "arguments", {
|
|
164
|
-
get: function () {
|
|
165
|
-
return this.options.args || [];
|
|
166
|
-
},
|
|
167
|
-
enumerable: false,
|
|
168
|
-
configurable: true
|
|
169
|
-
});
|
|
170
|
-
TerminalProcess.prototype.onTerminalExit = function (code, signal) {
|
|
132
|
+
}
|
|
133
|
+
get pid() {
|
|
134
|
+
this.checkTerminal();
|
|
135
|
+
return this.terminal.pid;
|
|
136
|
+
}
|
|
137
|
+
get executable() {
|
|
138
|
+
return this.options.command;
|
|
139
|
+
}
|
|
140
|
+
get arguments() {
|
|
141
|
+
return this.options.args || [];
|
|
142
|
+
}
|
|
143
|
+
onTerminalExit(code, signal) {
|
|
171
144
|
this.emitOnExit(code, signal);
|
|
172
145
|
this.unregisterProcess();
|
|
173
|
-
}
|
|
174
|
-
|
|
146
|
+
}
|
|
147
|
+
unregisterProcess() {
|
|
175
148
|
this.processManager.unregister(this);
|
|
176
|
-
}
|
|
177
|
-
|
|
149
|
+
}
|
|
150
|
+
kill(signal) {
|
|
178
151
|
if (this.terminal && this.killed === false) {
|
|
179
152
|
this.terminal.kill(signal);
|
|
180
153
|
}
|
|
181
|
-
}
|
|
182
|
-
|
|
154
|
+
}
|
|
155
|
+
resize(cols, rows) {
|
|
183
156
|
this.checkTerminal();
|
|
184
157
|
this.terminal.resize(cols, rows);
|
|
185
|
-
}
|
|
186
|
-
|
|
158
|
+
}
|
|
159
|
+
write(data) {
|
|
187
160
|
this.checkTerminal();
|
|
188
161
|
this.terminal.write(data);
|
|
189
|
-
}
|
|
190
|
-
|
|
162
|
+
}
|
|
163
|
+
checkTerminal() {
|
|
191
164
|
if (!this.terminal) {
|
|
192
165
|
throw new Error('pty process did not start correctly');
|
|
193
166
|
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}(process_1.Process));
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
TerminalProcess = __decorate([
|
|
170
|
+
inversify_1.injectable(),
|
|
171
|
+
__param(0, inversify_1.inject(exports.TerminalProcessOptions)),
|
|
172
|
+
__param(1, inversify_1.inject(process_manager_1.ProcessManager)),
|
|
173
|
+
__param(2, inversify_1.inject(multi_ring_buffer_1.MultiRingBuffer)),
|
|
174
|
+
__param(3, inversify_1.inject(common_1.ILogger)), __param(3, inversify_1.named('process')),
|
|
175
|
+
__metadata("design:paramtypes", [Object, process_manager_1.ProcessManager,
|
|
176
|
+
multi_ring_buffer_1.MultiRingBuffer, Object])
|
|
177
|
+
], TerminalProcess);
|
|
206
178
|
exports.TerminalProcess = TerminalProcess;
|
|
207
179
|
//# sourceMappingURL=terminal-process.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"terminal-process.js","sourceRoot":"","sources":["../../src/node/terminal-process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF
|
|
1
|
+
{"version":3,"file":"terminal-process.js","sourceRoot":"","sources":["../../src/node/terminal-process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;;;;AAElF,4DAAyE;AACzE,sCAAwC;AACxC,mDAAiD;AACjD,uCAAoF;AACpF,uDAAmD;AACnD,8CAA8C;AAC9C,2DAAqF;AACrF,uDAAkD;AAClD,mCAAkC;AAClC,6CAAyC;AACzC,mCAAkC;AAErB,QAAA,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAS1D,QAAA,sBAAsB,GAAG,MAAM,CAAC,wBAAwB,CAAC,CAAC;AAKvE;;;;GAIG;AAEH,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,iBAAO;IAQxC,YAAa,qDAAqD;IACX,OAA+B,EAC1D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MAAM,CAAC,CAAC;SAC9B;IACL,CAAC;IAED,MAAM,CAAC,IAAY,EAAE,IAAY;QAC7B,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,QAAS,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,IAAY;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,QAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAES,aAAa;QACnB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAChB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;SAC1D;IACL,CAAC;CAEJ,CAAA;AAnJY,eAAe;IAD3B,sBAAU,EAAE;IAUJ,WAAA,kBAAM,CAAC,8BAAsB,CAAC,CAAA;IAC9B,WAAA,kBAAM,CAAC,gCAAc,CAAC,CAAA;IACtB,WAAA,kBAAM,CAAC,mCAAe,CAAC,CAAA;IACvB,WAAA,kBAAM,CAAC,gBAAO,CAAC,CAAA,EAAE,WAAA,iBAAK,CAAC,SAAS,CAAC,CAAA;6CAFM,gCAAc;QACE,mCAAe;GAXlE,eAAe,CAmJ3B;AAnJY,0CAAe"}
|
|
@@ -1,40 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
/********************************************************************************
|
|
40
4
|
* Copyright (C) 2017 Ericsson and others.
|
|
@@ -51,117 +15,76 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
51
15
|
*
|
|
52
16
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
53
17
|
********************************************************************************/
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
18
|
+
const chai = require("chai");
|
|
19
|
+
const process = require("process");
|
|
20
|
+
const stream = require("stream");
|
|
21
|
+
const process_test_container_1 = require("./test/process-test-container");
|
|
22
|
+
const terminal_process_1 = require("./terminal-process");
|
|
23
|
+
const os_1 = require("@theia/core/lib/common/os");
|
|
60
24
|
/**
|
|
61
25
|
* Globals
|
|
62
26
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
beforeEach(
|
|
27
|
+
const expect = chai.expect;
|
|
28
|
+
let terminalProcessFactory;
|
|
29
|
+
beforeEach(() => {
|
|
66
30
|
terminalProcessFactory = process_test_container_1.createProcessTestContainer().get(terminal_process_1.TerminalProcessFactory);
|
|
67
31
|
});
|
|
68
32
|
describe('TerminalProcess', function () {
|
|
69
33
|
this.timeout(20000);
|
|
70
|
-
it('test error on non existent path', function () {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
var proc = terminalProcessFactory({ command: '/non-existent' });
|
|
77
|
-
proc.onStart(reject);
|
|
78
|
-
proc.onError(resolve);
|
|
79
|
-
proc.onExit(reject);
|
|
80
|
-
})];
|
|
81
|
-
case 1:
|
|
82
|
-
error = _a.sent();
|
|
83
|
-
expect(error.code).eq('ENOENT');
|
|
84
|
-
return [2 /*return*/];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
34
|
+
it('test error on non existent path', async function () {
|
|
35
|
+
const error = await new Promise((resolve, reject) => {
|
|
36
|
+
const proc = terminalProcessFactory({ command: '/non-existent' });
|
|
37
|
+
proc.onStart(reject);
|
|
38
|
+
proc.onError(resolve);
|
|
39
|
+
proc.onExit(reject);
|
|
87
40
|
});
|
|
41
|
+
expect(error.code).eq('ENOENT');
|
|
88
42
|
});
|
|
89
|
-
it('test error on trying to execute a directory', function () {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
var proc = terminalProcessFactory({ command: __dirname });
|
|
96
|
-
proc.onStart(reject);
|
|
97
|
-
proc.onError(resolve);
|
|
98
|
-
proc.onExit(reject);
|
|
99
|
-
})];
|
|
100
|
-
case 1:
|
|
101
|
-
error = _a.sent();
|
|
102
|
-
if (os_1.isWindows) {
|
|
103
|
-
// On Windows, node-pty returns us a "File not found" message, so we can't really differentiate this case
|
|
104
|
-
// from trying to execute a non-existent file. node's child_process.spawn also returns ENOENT, so it's
|
|
105
|
-
// probably the best we can get.
|
|
106
|
-
expect(error.code).eq('ENOENT');
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
expect(error.code).eq('EACCES');
|
|
110
|
-
}
|
|
111
|
-
return [2 /*return*/];
|
|
112
|
-
}
|
|
113
|
-
});
|
|
43
|
+
it('test error on trying to execute a directory', async function () {
|
|
44
|
+
const error = await new Promise((resolve, reject) => {
|
|
45
|
+
const proc = terminalProcessFactory({ command: __dirname });
|
|
46
|
+
proc.onStart(reject);
|
|
47
|
+
proc.onError(resolve);
|
|
48
|
+
proc.onExit(reject);
|
|
114
49
|
});
|
|
50
|
+
if (os_1.isWindows) {
|
|
51
|
+
// On Windows, node-pty returns us a "File not found" message, so we can't really differentiate this case
|
|
52
|
+
// from trying to execute a non-existent file. node's child_process.spawn also returns ENOENT, so it's
|
|
53
|
+
// probably the best we can get.
|
|
54
|
+
expect(error.code).eq('ENOENT');
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
expect(error.code).eq('EACCES');
|
|
58
|
+
}
|
|
115
59
|
});
|
|
116
|
-
it('test exit', function () {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
args = ['--version'];
|
|
123
|
-
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
124
|
-
var proc = terminalProcessFactory({ command: process.execPath, args: args });
|
|
125
|
-
proc.onExit(resolve);
|
|
126
|
-
proc.onError(reject);
|
|
127
|
-
})];
|
|
128
|
-
case 1:
|
|
129
|
-
exit = _a.sent();
|
|
130
|
-
expect(exit.code).eq(0);
|
|
131
|
-
return [2 /*return*/];
|
|
132
|
-
}
|
|
133
|
-
});
|
|
60
|
+
it('test exit', async function () {
|
|
61
|
+
const args = ['--version'];
|
|
62
|
+
const exit = await new Promise((resolve, reject) => {
|
|
63
|
+
const proc = terminalProcessFactory({ command: process.execPath, args });
|
|
64
|
+
proc.onExit(resolve);
|
|
65
|
+
proc.onError(reject);
|
|
134
66
|
});
|
|
67
|
+
expect(exit.code).eq(0);
|
|
135
68
|
});
|
|
136
|
-
it('test pipe stream', function () {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
/* node-pty is not sending 'end' on the stream as it quits
|
|
152
|
-
only 'exit' is sent on the terminal process. */
|
|
153
|
-
terminalProcess.onExit(function () {
|
|
154
|
-
resolve(version.trim());
|
|
155
|
-
});
|
|
156
|
-
})];
|
|
157
|
-
case 1:
|
|
158
|
-
v = _a.sent();
|
|
159
|
-
/* Avoid using equal since terminal characters can be inserted at the end. */
|
|
160
|
-
expect(v).to.have.string(process.version);
|
|
161
|
-
return [2 /*return*/];
|
|
162
|
-
}
|
|
69
|
+
it('test pipe stream', async function () {
|
|
70
|
+
const v = await new Promise((resolve, reject) => {
|
|
71
|
+
const args = ['--version'];
|
|
72
|
+
const terminalProcess = terminalProcessFactory({ command: process.execPath, args });
|
|
73
|
+
terminalProcess.onError(reject);
|
|
74
|
+
const outStream = new stream.PassThrough();
|
|
75
|
+
terminalProcess.createOutputStream().pipe(outStream);
|
|
76
|
+
let version = '';
|
|
77
|
+
outStream.on('data', data => {
|
|
78
|
+
version += data.toString();
|
|
79
|
+
});
|
|
80
|
+
/* node-pty is not sending 'end' on the stream as it quits
|
|
81
|
+
only 'exit' is sent on the terminal process. */
|
|
82
|
+
terminalProcess.onExit(() => {
|
|
83
|
+
resolve(version.trim());
|
|
163
84
|
});
|
|
164
85
|
});
|
|
86
|
+
/* Avoid using equal since terminal characters can be inserted at the end. */
|
|
87
|
+
expect(v).to.have.string(process.version);
|
|
165
88
|
});
|
|
166
89
|
});
|
|
167
90
|
//# sourceMappingURL=terminal-process.spec.js.map
|