@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
package/lib/node/process.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/node/process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/node/process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;;;;AAElF,4DAAqE;AACrE,uDAAmD;AACnD,mDAAiE;AACjE,+CAA+C;AAC/C,sCAA+C;AAE/C,iDAAqC;AACrC,yBAAyB;AAsBzB,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,2CAAK,CAAA;IACL,qDAAU,CAAA;AACd,CAAC,EAHW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAGtB;AAkCD,IAAsB,OAAO,GAA7B,MAAsB,OAAO;IA6BzB,YACuB,cAA8B,EAC9B,MAAe,EACF,IAAiB,EAC9B,OAAqC;QAHrC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,WAAM,GAAN,MAAM,CAAS;QACF,SAAI,GAAJ,IAAI,CAAa;QAC9B,YAAO,GAAP,OAAO,CAA8B;QA9BzC,iBAAY,GAAgC,IAAI,gBAAO,EAAsB,CAAC;QAC9E,gBAAW,GAA+B,IAAI,gBAAO,EAAqB,CAAC;QAC3E,iBAAY,GAA+B,IAAI,gBAAO,EAAqB,CAAC;QAC5E,iBAAY,GAA+B,IAAI,gBAAO,EAAqB,CAAC;QACrF,YAAO,GAAG,KAAK,CAAC;QA4BtB,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAC7C,IAAI,CAAC,UAAU,GAAG,OAAO,IAAI,OAAO,CAAC,OAAO,IAAI,KAAK,IAAI,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,IAAI,SAAS,CAAC;IAC/H,CAAC;IAID,IAAI,MA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AAQ,EAAE,CAAC,CAAC;qBACvD;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;SACN;aAAM,IAAI,CAAC,gBAAS,EAAE;YACnB,OAAO,IAAI,OAAO,CAAS,OAAO,CAAC,EAAE;gBACjC,EAAE,CAAC,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,GAAG,MAAM,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,EAAE;oBACzD,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE;wBACnB,OAAO,CAAC,cAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;qBACvD;yBAAM;wBACH,OAAO,CAAC,cAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;qBACjD;gBACL,CAAC,CAAC,CAAC;YACP,CAAC,CAAC,CAAC;SACN;aAAM;YACH,OAAO,IAAI,OAAO,CAAS,OAAO,CAAC,EAAE;gBACjC,OAAO,CAAC,cAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YACxD,CAAC,CAAC,CAAC;SACN;IACL,CAAC;CACJ,CAAA;AArJqB,OAAO;IAD5B,sBAAU,EAAE;IAiCJ,WAAA,qBAAS,EAAE,CAAA;qCAFuB,gCAAc;GA9BnC,OAAO,CAqJ5B;AArJqB,0BAAO"}
|
package/lib/node/pseudo-pty.js
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
********************************************************************************/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.PseudoPty = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const core_1 = require("@theia/core");
|
|
20
|
+
class PseudoPty {
|
|
21
|
+
constructor() {
|
|
22
22
|
this.pid = -1;
|
|
23
23
|
this.cols = -1;
|
|
24
24
|
this.rows = -1;
|
|
@@ -28,11 +28,10 @@ var PseudoPty = /** @class */ (function () {
|
|
|
28
28
|
this.onExit = core_1.Event.None;
|
|
29
29
|
}
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}());
|
|
31
|
+
on(event, listener) { }
|
|
32
|
+
resize(columns, rows) { }
|
|
33
|
+
write(data) { }
|
|
34
|
+
kill(signal) { }
|
|
35
|
+
}
|
|
37
36
|
exports.PseudoPty = PseudoPty;
|
|
38
37
|
//# sourceMappingURL=pseudo-pty.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pseudo-pty.js","sourceRoot":"","sources":["../../src/node/pseudo-pty.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAGlF,
|
|
1
|
+
{"version":3,"file":"pseudo-pty.js","sourceRoot":"","sources":["../../src/node/pseudo-pty.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;AAGlF,sCAAoC;AAEpC,MAAa,SAAS;IAAtB;QAEa,QAAG,GAAW,CAAC,CAAC,CAAC;QAEjB,SAAI,GAAW,CAAC,CAAC,CAAC;QAElB,SAAI,GAAW,CAAC,CAAC,CAAC;QAElB,YAAO,GAAW,EAAE,CAAC;QAE9B,sBAAiB,GAAG,KAAK,CAAC;QAEjB,WAAM,GAAkB,YAAK,CAAC,IAAI,CAAC;QAEnC,WAAM,GAAiD,YAAK,CAAC,IAAI,CAAC;IAiB/E,CAAC;IATG,8DAA8D;IAC9D,EAAE,CAAC,KAAa,EAAE,QAAkC,IAAU,CAAC;IAE/D,MAAM,CAAC,OAAe,EAAE,IAAY,IAAU,CAAC;IAE/C,KAAK,CAAC,IAAY,IAAU,CAAC;IAE7B,IAAI,CAAC,MAAe,IAAU,CAAC;CAElC;AA/BD,8BA+BC"}
|
package/lib/node/raw-process.js
CHANGED
|
@@ -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,119 +28,100 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
41
28
|
};
|
|
42
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
30
|
exports.RawProcess = exports.RawProcessFactory = exports.RawProcessOptions = void 0;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
31
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
32
|
+
const process_manager_1 = require("./process-manager");
|
|
33
|
+
const common_1 = require("@theia/core/lib/common");
|
|
34
|
+
const process_1 = require("./process");
|
|
35
|
+
const child_process_1 = require("child_process");
|
|
49
36
|
// The class was here before, exporting to not break anything.
|
|
50
37
|
var dev_null_stream_1 = require("./dev-null-stream");
|
|
51
38
|
Object.defineProperty(exports, "DevNullStream", { enumerable: true, get: function () { return dev_null_stream_1.DevNullStream; } });
|
|
52
|
-
|
|
39
|
+
const dev_null_stream_2 = require("./dev-null-stream");
|
|
53
40
|
exports.RawProcessOptions = Symbol('RawProcessOptions');
|
|
54
41
|
exports.RawProcessFactory = Symbol('RawProcessFactory');
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
function RawProcess(// eslint-disable-next-line @typescript-eslint/indent
|
|
42
|
+
let RawProcess = class RawProcess extends process_1.Process {
|
|
43
|
+
constructor(// eslint-disable-next-line @typescript-eslint/indent
|
|
58
44
|
options, processManager, logger) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
+
|
|
63
|
-
+
|
|
45
|
+
super(processManager, logger, process_1.ProcessType.Raw, options);
|
|
46
|
+
const executable = this.isForkOptions(options) ? options.modulePath : options.command;
|
|
47
|
+
this.logger.debug(`Starting raw process: ${executable},`
|
|
48
|
+
+ ` with args: ${options.args ? options.args.join(' ') : ''}, `
|
|
49
|
+
+ ` with options: ${JSON.stringify(options.options)}`);
|
|
64
50
|
// About catching errors: spawn will sometimes throw directly
|
|
65
51
|
// (EACCES on Linux), sometimes return a Process object with the pid
|
|
66
52
|
// property undefined (ENOENT on Linux) and then emit an 'error' event.
|
|
67
53
|
// For now, we try to normalize that into always emitting an 'error'
|
|
68
54
|
// event.
|
|
69
55
|
try {
|
|
70
|
-
if (
|
|
71
|
-
|
|
56
|
+
if (this.isForkOptions(options)) {
|
|
57
|
+
this.process = child_process_1.fork(options.modulePath, options.args || [], options.options || {});
|
|
72
58
|
}
|
|
73
59
|
else {
|
|
74
|
-
|
|
60
|
+
this.process = child_process_1.spawn(options.command, options.args || [], options.options || {});
|
|
75
61
|
}
|
|
76
|
-
|
|
62
|
+
this.process.on('error', (error) => {
|
|
77
63
|
error.code = error.code || 'Unknown error';
|
|
78
|
-
|
|
64
|
+
this.emitOnError(error);
|
|
79
65
|
});
|
|
80
66
|
// When no stdio option is passed, it is null by default.
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
67
|
+
this.outputStream = this.process.stdout || new dev_null_stream_2.DevNullStream({ autoDestroy: true });
|
|
68
|
+
this.inputStream = this.process.stdin || new dev_null_stream_2.DevNullStream({ autoDestroy: true });
|
|
69
|
+
this.errorStream = this.process.stderr || new dev_null_stream_2.DevNullStream({ autoDestroy: true });
|
|
70
|
+
this.process.on('exit', (exitCode, signal) => {
|
|
85
71
|
// node's child_process exit sets the unused parameter to null,
|
|
86
72
|
// but we want it to be undefined instead.
|
|
87
|
-
|
|
88
|
-
|
|
73
|
+
this.emitOnExit(typeof exitCode === 'number' ? exitCode : undefined, typeof signal === 'string' ? signal : undefined);
|
|
74
|
+
this.processManager.unregister(this);
|
|
89
75
|
});
|
|
90
|
-
|
|
76
|
+
this.process.on('close', (exitCode, signal) => {
|
|
91
77
|
// node's child_process exit sets the unused parameter to null,
|
|
92
78
|
// but we want it to be undefined instead.
|
|
93
|
-
|
|
79
|
+
this.emitOnClose(typeof exitCode === 'number' ? exitCode : undefined, typeof signal === 'string' ? signal : undefined);
|
|
94
80
|
});
|
|
95
|
-
if (
|
|
96
|
-
process.nextTick(
|
|
81
|
+
if (this.process.pid !== undefined) {
|
|
82
|
+
process.nextTick(this.emitOnStarted.bind(this));
|
|
97
83
|
}
|
|
98
84
|
}
|
|
99
85
|
catch (error) {
|
|
100
86
|
/* When an error is thrown, set up some fake streams, so the client
|
|
101
87
|
code doesn't break because these field are undefined. */
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
88
|
+
this.outputStream = new dev_null_stream_2.DevNullStream({ autoDestroy: true });
|
|
89
|
+
this.inputStream = new dev_null_stream_2.DevNullStream({ autoDestroy: true });
|
|
90
|
+
this.errorStream = new dev_null_stream_2.DevNullStream({ autoDestroy: true });
|
|
105
91
|
/* Call the client error handler, but first give them a chance to register it. */
|
|
106
|
-
|
|
92
|
+
this.emitOnErrorAsync(error);
|
|
107
93
|
}
|
|
108
|
-
return _this;
|
|
109
94
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
*/
|
|
130
|
-
get: function () { return this.errorStream; },
|
|
131
|
-
enumerable: false,
|
|
132
|
-
configurable: true
|
|
133
|
-
});
|
|
134
|
-
Object.defineProperty(RawProcess.prototype, "pid", {
|
|
135
|
-
get: function () {
|
|
136
|
-
if (!this.process) {
|
|
137
|
-
throw new Error('process did not start correctly');
|
|
138
|
-
}
|
|
139
|
-
return this.process.pid;
|
|
140
|
-
},
|
|
141
|
-
enumerable: false,
|
|
142
|
-
configurable: true
|
|
143
|
-
});
|
|
144
|
-
RawProcess.prototype.kill = function (signal) {
|
|
95
|
+
/**
|
|
96
|
+
* @deprecated use `inputStream` instead.
|
|
97
|
+
*/
|
|
98
|
+
get input() { return this.inputStream; }
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated use `outputStream` instead.
|
|
101
|
+
*/
|
|
102
|
+
get output() { return this.outputStream; }
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated use `errorStream` instead.
|
|
105
|
+
*/
|
|
106
|
+
get errorOutput() { return this.errorStream; }
|
|
107
|
+
get pid() {
|
|
108
|
+
if (!this.process) {
|
|
109
|
+
throw new Error('process did not start correctly');
|
|
110
|
+
}
|
|
111
|
+
return this.process.pid;
|
|
112
|
+
}
|
|
113
|
+
kill(signal) {
|
|
145
114
|
if (this.process && this.killed === false) {
|
|
146
115
|
this.process.kill(signal);
|
|
147
116
|
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}(process_1.Process));
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
RawProcess = __decorate([
|
|
120
|
+
inversify_1.injectable(),
|
|
121
|
+
__param(0, inversify_1.inject(exports.RawProcessOptions)),
|
|
122
|
+
__param(1, inversify_1.inject(process_manager_1.ProcessManager)),
|
|
123
|
+
__param(2, inversify_1.inject(common_1.ILogger)), __param(2, inversify_1.named('process')),
|
|
124
|
+
__metadata("design:paramtypes", [Object, process_manager_1.ProcessManager, Object])
|
|
125
|
+
], RawProcess);
|
|
158
126
|
exports.RawProcess = RawProcess;
|
|
159
127
|
//# sourceMappingURL=raw-process.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"raw-process.js","sourceRoot":"","sources":["../../src/node/raw-process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF
|
|
1
|
+
{"version":3,"file":"raw-process.js","sourceRoot":"","sources":["../../src/node/raw-process.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;kFAckF;;;;;;;;;;;;;;;AAElF,4DAAyE;AACzE,uDAAmD;AACnD,mDAAiD;AACjD,uCAAiG;AACjG,iDAA0D;AAG1D,8DAA8D;AAC9D,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,uDAAkD;AAErC,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAwBhD,QAAA,iBAAiB,GAAG,MAAM,CAAC,mBAAmB,CAAC,CAAC;AAM7D,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,iBAAO;IA0BnC,YAAa,qDAAqD;IACnC,OAA2C,EAC9C,cAA8B,EACnB,MAAe;QAElD,KAAK,CAAC,cAAc,EAAE,MAAM,EAAE,qBAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACxD,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,UAAU,CA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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,239 +15,151 @@ 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
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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 raw_process_1 = require("./raw-process");
|
|
23
|
+
const temp = require("temp");
|
|
24
|
+
const fs = require("fs");
|
|
25
|
+
const path = require("path");
|
|
26
|
+
const core_1 = require("@theia/core");
|
|
63
27
|
/* Allow to create temporary files, but delete them when we're done. */
|
|
64
|
-
|
|
28
|
+
const track = temp.track();
|
|
65
29
|
/**
|
|
66
30
|
* Globals
|
|
67
31
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
32
|
+
const expect = chai.expect;
|
|
33
|
+
const FORK_TEST_FILE = path.join(__dirname, '../../src/node/test/process-fork-test.js');
|
|
70
34
|
describe('RawProcess', function () {
|
|
71
35
|
this.timeout(20000);
|
|
72
|
-
|
|
73
|
-
beforeEach(
|
|
36
|
+
let rawProcessFactory;
|
|
37
|
+
beforeEach(() => {
|
|
74
38
|
rawProcessFactory = process_test_container_1.createProcessTestContainer().get(raw_process_1.RawProcessFactory);
|
|
75
39
|
});
|
|
76
|
-
after(
|
|
40
|
+
after(() => {
|
|
77
41
|
track.cleanupSync();
|
|
78
42
|
});
|
|
79
|
-
it('test error on non-existent path', function () {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
var proc = rawProcessFactory({ command: '/non-existent' });
|
|
86
|
-
proc.onStart(reject);
|
|
87
|
-
proc.onError(resolve);
|
|
88
|
-
proc.onExit(reject);
|
|
89
|
-
})];
|
|
90
|
-
case 1:
|
|
91
|
-
error = _a.sent();
|
|
92
|
-
expect(error.code).eq('ENOENT');
|
|
93
|
-
return [2 /*return*/];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
43
|
+
it('test error on non-existent path', async function () {
|
|
44
|
+
const error = await new Promise((resolve, reject) => {
|
|
45
|
+
const proc = rawProcessFactory({ command: '/non-existent' });
|
|
46
|
+
proc.onStart(reject);
|
|
47
|
+
proc.onError(resolve);
|
|
48
|
+
proc.onExit(reject);
|
|
96
49
|
});
|
|
50
|
+
expect(error.code).eq('ENOENT');
|
|
97
51
|
});
|
|
98
|
-
it('test error on non-executable path', function () {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
proc.onStart(reject);
|
|
115
|
-
proc.onError(resolve);
|
|
116
|
-
proc.onExit(reject);
|
|
117
|
-
})];
|
|
118
|
-
case 1:
|
|
119
|
-
error = _a.sent();
|
|
120
|
-
expectedCode = core_1.isWindows ? 'UNKNOWN' : 'EACCES';
|
|
121
|
-
expect(error.code).eq(expectedCode);
|
|
122
|
-
return [2 /*return*/];
|
|
123
|
-
}
|
|
124
|
-
});
|
|
52
|
+
it('test error on non-executable path', async function () {
|
|
53
|
+
// Create a non-executable file.
|
|
54
|
+
const f = track.openSync('non-executable');
|
|
55
|
+
fs.writeSync(f.fd, 'echo bob');
|
|
56
|
+
// Make really sure it's non-executable.
|
|
57
|
+
let mode = fs.fstatSync(f.fd).mode;
|
|
58
|
+
mode &= ~fs.constants.S_IXUSR;
|
|
59
|
+
mode &= ~fs.constants.S_IXGRP;
|
|
60
|
+
mode &= ~fs.constants.S_IXOTH;
|
|
61
|
+
fs.fchmodSync(f.fd, mode);
|
|
62
|
+
fs.closeSync(f.fd);
|
|
63
|
+
const error = await new Promise((resolve, reject) => {
|
|
64
|
+
const proc = rawProcessFactory({ command: f.path });
|
|
65
|
+
proc.onStart(reject);
|
|
66
|
+
proc.onError(resolve);
|
|
67
|
+
proc.onExit(reject);
|
|
125
68
|
});
|
|
69
|
+
// On Windows, we get 'UNKNOWN'.
|
|
70
|
+
const expectedCode = core_1.isWindows ? 'UNKNOWN' : 'EACCES';
|
|
71
|
+
expect(error.code).eq(expectedCode);
|
|
126
72
|
});
|
|
127
73
|
it('test start event', function () {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
rawProcess.onError(reject);
|
|
136
|
-
rawProcess.onExit(reject);
|
|
137
|
-
return [2 /*return*/];
|
|
138
|
-
});
|
|
139
|
-
}); });
|
|
74
|
+
return new Promise(async (resolve, reject) => {
|
|
75
|
+
const args = ['-e', 'process.exit(3)'];
|
|
76
|
+
const rawProcess = rawProcessFactory({ command: process.execPath, 'args': args });
|
|
77
|
+
rawProcess.onStart(resolve);
|
|
78
|
+
rawProcess.onError(reject);
|
|
79
|
+
rawProcess.onExit(reject);
|
|
80
|
+
});
|
|
140
81
|
});
|
|
141
|
-
it('test exit', function () {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
reject();
|
|
152
|
-
});
|
|
153
|
-
rawProcess.onExit(function (event) {
|
|
154
|
-
if (event.code === undefined) {
|
|
155
|
-
reject();
|
|
156
|
-
}
|
|
157
|
-
resolve(event.code);
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
return [4 /*yield*/, p];
|
|
161
|
-
case 1:
|
|
162
|
-
exitCode = _a.sent();
|
|
163
|
-
expect(exitCode).equal(0);
|
|
164
|
-
return [2 /*return*/];
|
|
82
|
+
it('test exit', async function () {
|
|
83
|
+
const args = ['--version'];
|
|
84
|
+
const rawProcess = rawProcessFactory({ command: process.execPath, 'args': args });
|
|
85
|
+
const p = new Promise((resolve, reject) => {
|
|
86
|
+
rawProcess.onError(error => {
|
|
87
|
+
reject();
|
|
88
|
+
});
|
|
89
|
+
rawProcess.onExit(event => {
|
|
90
|
+
if (event.code === undefined) {
|
|
91
|
+
reject();
|
|
165
92
|
}
|
|
93
|
+
resolve(event.code);
|
|
166
94
|
});
|
|
167
95
|
});
|
|
96
|
+
const exitCode = await p;
|
|
97
|
+
expect(exitCode).equal(0);
|
|
168
98
|
});
|
|
169
|
-
it('test pipe stdout stream', function () {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
rawProcess.outputStream.pipe(outStream);
|
|
183
|
-
buf = '';
|
|
184
|
-
outStream.on('data', function (data) {
|
|
185
|
-
buf += data.toString();
|
|
186
|
-
});
|
|
187
|
-
outStream.on('end', function () {
|
|
188
|
-
resolve(buf.trim());
|
|
189
|
-
});
|
|
190
|
-
return [2 /*return*/];
|
|
191
|
-
});
|
|
192
|
-
}); })];
|
|
193
|
-
case 1:
|
|
194
|
-
output = _a.sent();
|
|
195
|
-
expect(output).to.be.equal('text to stdout');
|
|
196
|
-
return [2 /*return*/];
|
|
197
|
-
}
|
|
99
|
+
it('test pipe stdout stream', async function () {
|
|
100
|
+
const output = await new Promise(async (resolve, reject) => {
|
|
101
|
+
const args = ['-e', 'console.log("text to stdout")'];
|
|
102
|
+
const outStream = new stream.PassThrough();
|
|
103
|
+
const rawProcess = rawProcessFactory({ command: process.execPath, 'args': args });
|
|
104
|
+
rawProcess.onError(reject);
|
|
105
|
+
rawProcess.outputStream.pipe(outStream);
|
|
106
|
+
let buf = '';
|
|
107
|
+
outStream.on('data', data => {
|
|
108
|
+
buf += data.toString();
|
|
109
|
+
});
|
|
110
|
+
outStream.on('end', () => {
|
|
111
|
+
resolve(buf.trim());
|
|
198
112
|
});
|
|
199
113
|
});
|
|
114
|
+
expect(output).to.be.equal('text to stdout');
|
|
200
115
|
});
|
|
201
|
-
it('test pipe stderr stream', function () {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
rawProcess.errorStream.pipe(outStream);
|
|
215
|
-
buf = '';
|
|
216
|
-
outStream.on('data', function (data) {
|
|
217
|
-
buf += data.toString();
|
|
218
|
-
});
|
|
219
|
-
outStream.on('end', function () {
|
|
220
|
-
resolve(buf.trim());
|
|
221
|
-
});
|
|
222
|
-
return [2 /*return*/];
|
|
223
|
-
});
|
|
224
|
-
}); })];
|
|
225
|
-
case 1:
|
|
226
|
-
output = _a.sent();
|
|
227
|
-
expect(output).to.be.equal('text to stderr');
|
|
228
|
-
return [2 /*return*/];
|
|
229
|
-
}
|
|
116
|
+
it('test pipe stderr stream', async function () {
|
|
117
|
+
const output = await new Promise(async (resolve, reject) => {
|
|
118
|
+
const args = ['-e', 'console.error("text to stderr")'];
|
|
119
|
+
const outStream = new stream.PassThrough();
|
|
120
|
+
const rawProcess = rawProcessFactory({ command: process.execPath, 'args': args });
|
|
121
|
+
rawProcess.onError(reject);
|
|
122
|
+
rawProcess.errorStream.pipe(outStream);
|
|
123
|
+
let buf = '';
|
|
124
|
+
outStream.on('data', data => {
|
|
125
|
+
buf += data.toString();
|
|
126
|
+
});
|
|
127
|
+
outStream.on('end', () => {
|
|
128
|
+
resolve(buf.trim());
|
|
230
129
|
});
|
|
231
130
|
});
|
|
131
|
+
expect(output).to.be.equal('text to stderr');
|
|
232
132
|
});
|
|
233
|
-
it('test forked pipe stdout stream', function () {
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
outStream.on('data', function (data) {
|
|
245
|
-
version += data.toString();
|
|
246
|
-
});
|
|
247
|
-
outStream.on('end', function () {
|
|
248
|
-
resolve(version.trim());
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
rawProcess.outputStream.pipe(outStream);
|
|
252
|
-
_a = expect;
|
|
253
|
-
return [4 /*yield*/, p];
|
|
254
|
-
case 1:
|
|
255
|
-
_a.apply(void 0, [_b.sent()]).to.be.equal('1.0.0');
|
|
256
|
-
return [2 /*return*/];
|
|
257
|
-
}
|
|
133
|
+
it('test forked pipe stdout stream', async function () {
|
|
134
|
+
const args = ['version'];
|
|
135
|
+
const rawProcess = rawProcessFactory({ modulePath: FORK_TEST_FILE, args, options: { stdio: 'pipe' } });
|
|
136
|
+
const outStream = new stream.PassThrough();
|
|
137
|
+
const p = new Promise((resolve, reject) => {
|
|
138
|
+
let version = '';
|
|
139
|
+
outStream.on('data', data => {
|
|
140
|
+
version += data.toString();
|
|
141
|
+
});
|
|
142
|
+
outStream.on('end', () => {
|
|
143
|
+
resolve(version.trim());
|
|
258
144
|
});
|
|
259
145
|
});
|
|
146
|
+
rawProcess.outputStream.pipe(outStream);
|
|
147
|
+
expect(await p).to.be.equal('1.0.0');
|
|
260
148
|
});
|
|
261
|
-
it('test forked pipe stderr stream', function () {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
outStream.on('data', function (data) {
|
|
272
|
-
version += data.toString();
|
|
273
|
-
});
|
|
274
|
-
outStream.on('end', function () {
|
|
275
|
-
resolve(version.trim());
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
rawProcess.errorStream.pipe(outStream);
|
|
279
|
-
_a = expect;
|
|
280
|
-
return [4 /*yield*/, p];
|
|
281
|
-
case 1:
|
|
282
|
-
_a.apply(void 0, [_b.sent()]).to.have.string('Error');
|
|
283
|
-
return [2 /*return*/];
|
|
284
|
-
}
|
|
149
|
+
it('test forked pipe stderr stream', async function () {
|
|
150
|
+
const rawProcess = rawProcessFactory({ modulePath: FORK_TEST_FILE, args: [], options: { stdio: 'pipe' } });
|
|
151
|
+
const outStream = new stream.PassThrough();
|
|
152
|
+
const p = new Promise((resolve, reject) => {
|
|
153
|
+
let version = '';
|
|
154
|
+
outStream.on('data', data => {
|
|
155
|
+
version += data.toString();
|
|
156
|
+
});
|
|
157
|
+
outStream.on('end', () => {
|
|
158
|
+
resolve(version.trim());
|
|
285
159
|
});
|
|
286
160
|
});
|
|
161
|
+
rawProcess.errorStream.pipe(outStream);
|
|
162
|
+
expect(await p).to.have.string('Error');
|
|
287
163
|
});
|
|
288
164
|
});
|
|
289
165
|
//# sourceMappingURL=raw-process.spec.js.map
|