@theia/process 1.34.2 → 1.34.3

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.
Files changed (70) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +30 -30
  3. package/lib/common/process-common-module.d.ts +3 -3
  4. package/lib/common/process-common-module.js +22 -22
  5. package/lib/common/process-manager-types.d.ts +35 -35
  6. package/lib/common/process-manager-types.js +23 -23
  7. package/lib/common/shell-command-builder.d.ts +49 -49
  8. package/lib/common/shell-command-builder.js +174 -174
  9. package/lib/common/shell-command-builder.slow-spec.d.ts +9 -9
  10. package/lib/common/shell-command-builder.slow-spec.js +404 -404
  11. package/lib/common/shell-quoting.d.ts +91 -91
  12. package/lib/common/shell-quoting.js +145 -145
  13. package/lib/common/shell-quoting.spec.d.ts +1 -1
  14. package/lib/common/shell-quoting.spec.js +170 -170
  15. package/lib/node/dev-null-stream.d.ts +17 -17
  16. package/lib/node/dev-null-stream.js +41 -41
  17. package/lib/node/index.d.ts +6 -6
  18. package/lib/node/index.js +33 -33
  19. package/lib/node/multi-ring-buffer.d.ts +68 -68
  20. package/lib/node/multi-ring-buffer.js +310 -310
  21. package/lib/node/multi-ring-buffer.spec.d.ts +1 -1
  22. package/lib/node/multi-ring-buffer.spec.js +422 -422
  23. package/lib/node/process-backend-module.d.ts +3 -3
  24. package/lib/node/process-backend-module.js +56 -56
  25. package/lib/node/process-manager.d.ts +33 -33
  26. package/lib/node/process-manager.js +113 -113
  27. package/lib/node/process.d.ts +95 -95
  28. package/lib/node/process.js +153 -153
  29. package/lib/node/pseudo-pty.d.ts +22 -22
  30. package/lib/node/pseudo-pty.js +38 -38
  31. package/lib/node/raw-process.d.ts +45 -45
  32. package/lib/node/raw-process.js +115 -115
  33. package/lib/node/raw-process.spec.d.ts +1 -1
  34. package/lib/node/raw-process.spec.js +164 -164
  35. package/lib/node/task-terminal-process.d.ts +10 -10
  36. package/lib/node/task-terminal-process.js +47 -47
  37. package/lib/node/terminal-process.d.ts +49 -49
  38. package/lib/node/terminal-process.js +180 -180
  39. package/lib/node/terminal-process.spec.d.ts +1 -1
  40. package/lib/node/terminal-process.spec.js +89 -89
  41. package/lib/node/test/process-test-container.d.ts +2 -2
  42. package/lib/node/test/process-test-container.js +28 -28
  43. package/lib/node/utils.d.ts +16 -16
  44. package/lib/node/utils.js +77 -77
  45. package/package.json +4 -4
  46. package/src/common/process-common-module.ts +22 -22
  47. package/src/common/process-manager-types.ts +58 -58
  48. package/src/common/shell-command-builder.slow-spec.ts +486 -486
  49. package/src/common/shell-command-builder.ts +187 -187
  50. package/src/common/shell-quoting.spec.ts +176 -176
  51. package/src/common/shell-quoting.ts +236 -236
  52. package/src/common/tests/$weird(),file=name.js +1 -1
  53. package/src/common/tests/white space.js +1 -1
  54. package/src/node/dev-null-stream.ts +47 -47
  55. package/src/node/index.ts +22 -22
  56. package/src/node/multi-ring-buffer.spec.ts +486 -486
  57. package/src/node/multi-ring-buffer.ts +348 -348
  58. package/src/node/process-backend-module.ts +67 -67
  59. package/src/node/process-manager.ts +107 -107
  60. package/src/node/process.ts +207 -207
  61. package/src/node/pseudo-pty.ts +54 -54
  62. package/src/node/raw-process.spec.ts +199 -199
  63. package/src/node/raw-process.ts +156 -156
  64. package/src/node/string-argv.d.ts +21 -21
  65. package/src/node/task-terminal-process.ts +41 -41
  66. package/src/node/terminal-process.spec.ts +104 -104
  67. package/src/node/terminal-process.ts +198 -198
  68. package/src/node/test/process-fork-test.js +22 -22
  69. package/src/node/test/process-test-container.ts +27 -27
  70. package/src/node/utils.ts +79 -79
@@ -1,4 +1,4 @@
1
- import { ContainerModule } from '@theia/core/shared/inversify';
2
- declare const _default: ContainerModule;
3
- export default _default;
1
+ import { ContainerModule } from '@theia/core/shared/inversify';
2
+ declare const _default: ContainerModule;
3
+ export default _default;
4
4
  //# sourceMappingURL=process-backend-module.d.ts.map
@@ -1,57 +1,57 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 Ericsson and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- const inversify_1 = require("@theia/core/shared/inversify");
19
- const raw_process_1 = require("./raw-process");
20
- const terminal_process_1 = require("./terminal-process");
21
- const task_terminal_process_1 = require("./task-terminal-process");
22
- const node_1 = require("@theia/core/lib/node");
23
- const process_manager_1 = require("./process-manager");
24
- const common_1 = require("@theia/core/lib/common");
25
- const multi_ring_buffer_1 = require("./multi-ring-buffer");
26
- exports.default = new inversify_1.ContainerModule(bind => {
27
- bind(raw_process_1.RawProcess).toSelf().inTransientScope();
28
- bind(process_manager_1.ProcessManager).toSelf().inSingletonScope();
29
- bind(node_1.BackendApplicationContribution).toService(process_manager_1.ProcessManager);
30
- bind(common_1.ILogger).toDynamicValue(ctx => {
31
- const parentLogger = ctx.container.get(common_1.ILogger);
32
- return parentLogger.child('process');
33
- }).inSingletonScope().whenTargetNamed('process');
34
- bind(raw_process_1.RawProcessFactory).toFactory(ctx => (options) => {
35
- const child = new inversify_1.Container({ defaultScope: 'Singleton' });
36
- child.parent = ctx.container;
37
- child.bind(raw_process_1.RawProcessOptions).toConstantValue(options);
38
- return child.get(raw_process_1.RawProcess);
39
- });
40
- bind(terminal_process_1.TerminalProcess).toSelf().inTransientScope();
41
- bind(terminal_process_1.TerminalProcessFactory).toFactory(ctx => (options) => {
42
- const child = new inversify_1.Container({ defaultScope: 'Singleton' });
43
- child.parent = ctx.container;
44
- child.bind(terminal_process_1.TerminalProcessOptions).toConstantValue(options);
45
- return child.get(terminal_process_1.TerminalProcess);
46
- });
47
- bind(task_terminal_process_1.TaskTerminalProcess).toSelf().inTransientScope();
48
- bind(task_terminal_process_1.TaskTerminalProcessFactory).toFactory(ctx => (options) => {
49
- const child = ctx.container.createChild();
50
- child.bind(terminal_process_1.TerminalProcessOptions).toConstantValue(options);
51
- return child.get(task_terminal_process_1.TaskTerminalProcess);
52
- });
53
- bind(multi_ring_buffer_1.MultiRingBuffer).toSelf().inTransientScope();
54
- /* 1MB size, TODO should be a user preference. */
55
- bind(multi_ring_buffer_1.MultiRingBufferOptions).toConstantValue({ size: 1048576 });
56
- });
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 Ericsson and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ const inversify_1 = require("@theia/core/shared/inversify");
19
+ const raw_process_1 = require("./raw-process");
20
+ const terminal_process_1 = require("./terminal-process");
21
+ const task_terminal_process_1 = require("./task-terminal-process");
22
+ const node_1 = require("@theia/core/lib/node");
23
+ const process_manager_1 = require("./process-manager");
24
+ const common_1 = require("@theia/core/lib/common");
25
+ const multi_ring_buffer_1 = require("./multi-ring-buffer");
26
+ exports.default = new inversify_1.ContainerModule(bind => {
27
+ bind(raw_process_1.RawProcess).toSelf().inTransientScope();
28
+ bind(process_manager_1.ProcessManager).toSelf().inSingletonScope();
29
+ bind(node_1.BackendApplicationContribution).toService(process_manager_1.ProcessManager);
30
+ bind(common_1.ILogger).toDynamicValue(ctx => {
31
+ const parentLogger = ctx.container.get(common_1.ILogger);
32
+ return parentLogger.child('process');
33
+ }).inSingletonScope().whenTargetNamed('process');
34
+ bind(raw_process_1.RawProcessFactory).toFactory(ctx => (options) => {
35
+ const child = new inversify_1.Container({ defaultScope: 'Singleton' });
36
+ child.parent = ctx.container;
37
+ child.bind(raw_process_1.RawProcessOptions).toConstantValue(options);
38
+ return child.get(raw_process_1.RawProcess);
39
+ });
40
+ bind(terminal_process_1.TerminalProcess).toSelf().inTransientScope();
41
+ bind(terminal_process_1.TerminalProcessFactory).toFactory(ctx => (options) => {
42
+ const child = new inversify_1.Container({ defaultScope: 'Singleton' });
43
+ child.parent = ctx.container;
44
+ child.bind(terminal_process_1.TerminalProcessOptions).toConstantValue(options);
45
+ return child.get(terminal_process_1.TerminalProcess);
46
+ });
47
+ bind(task_terminal_process_1.TaskTerminalProcess).toSelf().inTransientScope();
48
+ bind(task_terminal_process_1.TaskTerminalProcessFactory).toFactory(ctx => (options) => {
49
+ const child = ctx.container.createChild();
50
+ child.bind(terminal_process_1.TerminalProcessOptions).toConstantValue(options);
51
+ return child.get(task_terminal_process_1.TaskTerminalProcess);
52
+ });
53
+ bind(multi_ring_buffer_1.MultiRingBuffer).toSelf().inTransientScope();
54
+ /* 1MB size, TODO should be a user preference. */
55
+ bind(multi_ring_buffer_1.MultiRingBufferOptions).toConstantValue({ size: 1048576 });
56
+ });
57
57
  //# sourceMappingURL=process-backend-module.js.map
@@ -1,34 +1,34 @@
1
- import { Emitter, Event } from '@theia/core/lib/common';
2
- import { ILogger } from '@theia/core/lib/common/logger';
3
- import { BackendApplicationContribution } from '@theia/core/lib/node';
4
- import { ManagedProcessManager, ManagedProcess } from '../common/process-manager-types';
5
- import { Process } from './process';
6
- export declare class ProcessManager implements ManagedProcessManager, BackendApplicationContribution {
7
- protected logger: ILogger;
8
- protected readonly processes: Map<number, Process>;
9
- protected readonly deleteEmitter: Emitter<number>;
10
- constructor(logger: ILogger);
11
- /**
12
- * Registers the given process into this manager. Both on process termination and on error,
13
- * the process will be automatically removed from the manager.
14
- *
15
- * @param process the process to register.
16
- */
17
- register(process: Process): number;
18
- /**
19
- * @returns a random id for a process that is not assigned to a different process yet.
20
- */
21
- protected generateId(): number;
22
- /**
23
- * Removes the process from this process manager. Invoking this method, will make
24
- * sure that the process is terminated before eliminating it from the manager's cache.
25
- *
26
- * @param process the process to unregister from this process manager.
27
- */
28
- unregister(process: ManagedProcess): void;
29
- get(id: number): ManagedProcess | undefined;
30
- get onDelete(): Event<number>;
31
- onStop(): void;
32
- private getProcessLabel;
33
- }
1
+ import { Emitter, Event } from '@theia/core/lib/common';
2
+ import { ILogger } from '@theia/core/lib/common/logger';
3
+ import { BackendApplicationContribution } from '@theia/core/lib/node';
4
+ import { ManagedProcessManager, ManagedProcess } from '../common/process-manager-types';
5
+ import { Process } from './process';
6
+ export declare class ProcessManager implements ManagedProcessManager, BackendApplicationContribution {
7
+ protected logger: ILogger;
8
+ protected readonly processes: Map<number, Process>;
9
+ protected readonly deleteEmitter: Emitter<number>;
10
+ constructor(logger: ILogger);
11
+ /**
12
+ * Registers the given process into this manager. Both on process termination and on error,
13
+ * the process will be automatically removed from the manager.
14
+ *
15
+ * @param process the process to register.
16
+ */
17
+ register(process: Process): number;
18
+ /**
19
+ * @returns a random id for a process that is not assigned to a different process yet.
20
+ */
21
+ protected generateId(): number;
22
+ /**
23
+ * Removes the process from this process manager. Invoking this method, will make
24
+ * sure that the process is terminated before eliminating it from the manager's cache.
25
+ *
26
+ * @param process the process to unregister from this process manager.
27
+ */
28
+ unregister(process: ManagedProcess): void;
29
+ get(id: number): ManagedProcess | undefined;
30
+ get onDelete(): Event<number>;
31
+ onStop(): void;
32
+ private getProcessLabel;
33
+ }
34
34
  //# sourceMappingURL=process-manager.d.ts.map
@@ -1,114 +1,114 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.ProcessManager = void 0;
16
- // *****************************************************************************
17
- // Copyright (C) 2017 Ericsson and others.
18
- //
19
- // This program and the accompanying materials are made available under the
20
- // terms of the Eclipse Public License v. 2.0 which is available at
21
- // http://www.eclipse.org/legal/epl-2.0.
22
- //
23
- // This Source Code may also be made available under the following Secondary
24
- // Licenses when the conditions for such availability set forth in the Eclipse
25
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
26
- // with the GNU Classpath Exception which is available at
27
- // https://www.gnu.org/software/classpath/license.html.
28
- //
29
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
30
- // *****************************************************************************
31
- const inversify_1 = require("@theia/core/shared/inversify");
32
- const common_1 = require("@theia/core/lib/common");
33
- const logger_1 = require("@theia/core/lib/common/logger");
34
- const numbers_1 = require("@theia/core/lib/common/numbers");
35
- let ProcessManager = class ProcessManager {
36
- constructor(logger) {
37
- this.logger = logger;
38
- this.processes = new Map();
39
- this.deleteEmitter = new common_1.Emitter();
40
- }
41
- /**
42
- * Registers the given process into this manager. Both on process termination and on error,
43
- * the process will be automatically removed from the manager.
44
- *
45
- * @param process the process to register.
46
- */
47
- register(process) {
48
- const id = this.generateId();
49
- this.processes.set(id, process);
50
- process.onError(() => this.unregister(process));
51
- return id;
52
- }
53
- /**
54
- * @returns a random id for a process that is not assigned to a different process yet.
55
- */
56
- generateId() {
57
- let id = undefined;
58
- while (id === undefined) {
59
- const candidate = Math.floor(Math.random() * numbers_1.MAX_SAFE_INTEGER);
60
- if (!this.processes.has(candidate)) {
61
- id = candidate;
62
- }
63
- }
64
- return id;
65
- }
66
- /**
67
- * Removes the process from this process manager. Invoking this method, will make
68
- * sure that the process is terminated before eliminating it from the manager's cache.
69
- *
70
- * @param process the process to unregister from this process manager.
71
- */
72
- unregister(process) {
73
- const processLabel = this.getProcessLabel(process);
74
- this.logger.debug(`Unregistering process. ${processLabel}`);
75
- if (!process.killed) {
76
- this.logger.debug(`Ensuring process termination. ${processLabel}`);
77
- process.kill();
78
- }
79
- if (this.processes.delete(process.id)) {
80
- this.deleteEmitter.fire(process.id);
81
- this.logger.debug(`The process was successfully unregistered. ${processLabel}`);
82
- }
83
- else {
84
- this.logger.warn(`This process was not registered or was already unregistered. ${processLabel}`);
85
- }
86
- }
87
- get(id) {
88
- return this.processes.get(id);
89
- }
90
- get onDelete() {
91
- return this.deleteEmitter.event;
92
- }
93
- onStop() {
94
- for (const process of this.processes.values()) {
95
- try {
96
- this.unregister(process);
97
- }
98
- catch (error) {
99
- this.logger.error(`Error occurred when unregistering process. ${this.getProcessLabel(process)}`, error);
100
- }
101
- }
102
- }
103
- getProcessLabel(process) {
104
- return `[ID: ${process.id}]`;
105
- }
106
- };
107
- ProcessManager = __decorate([
108
- (0, inversify_1.injectable)(),
109
- __param(0, (0, inversify_1.inject)(logger_1.ILogger)),
110
- __param(0, (0, inversify_1.named)('process')),
111
- __metadata("design:paramtypes", [Object])
112
- ], ProcessManager);
113
- exports.ProcessManager = ProcessManager;
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ProcessManager = void 0;
16
+ // *****************************************************************************
17
+ // Copyright (C) 2017 Ericsson and others.
18
+ //
19
+ // This program and the accompanying materials are made available under the
20
+ // terms of the Eclipse Public License v. 2.0 which is available at
21
+ // http://www.eclipse.org/legal/epl-2.0.
22
+ //
23
+ // This Source Code may also be made available under the following Secondary
24
+ // Licenses when the conditions for such availability set forth in the Eclipse
25
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
26
+ // with the GNU Classpath Exception which is available at
27
+ // https://www.gnu.org/software/classpath/license.html.
28
+ //
29
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
30
+ // *****************************************************************************
31
+ const inversify_1 = require("@theia/core/shared/inversify");
32
+ const common_1 = require("@theia/core/lib/common");
33
+ const logger_1 = require("@theia/core/lib/common/logger");
34
+ const numbers_1 = require("@theia/core/lib/common/numbers");
35
+ let ProcessManager = class ProcessManager {
36
+ constructor(logger) {
37
+ this.logger = logger;
38
+ this.processes = new Map();
39
+ this.deleteEmitter = new common_1.Emitter();
40
+ }
41
+ /**
42
+ * Registers the given process into this manager. Both on process termination and on error,
43
+ * the process will be automatically removed from the manager.
44
+ *
45
+ * @param process the process to register.
46
+ */
47
+ register(process) {
48
+ const id = this.generateId();
49
+ this.processes.set(id, process);
50
+ process.onError(() => this.unregister(process));
51
+ return id;
52
+ }
53
+ /**
54
+ * @returns a random id for a process that is not assigned to a different process yet.
55
+ */
56
+ generateId() {
57
+ let id = undefined;
58
+ while (id === undefined) {
59
+ const candidate = Math.floor(Math.random() * numbers_1.MAX_SAFE_INTEGER);
60
+ if (!this.processes.has(candidate)) {
61
+ id = candidate;
62
+ }
63
+ }
64
+ return id;
65
+ }
66
+ /**
67
+ * Removes the process from this process manager. Invoking this method, will make
68
+ * sure that the process is terminated before eliminating it from the manager's cache.
69
+ *
70
+ * @param process the process to unregister from this process manager.
71
+ */
72
+ unregister(process) {
73
+ const processLabel = this.getProcessLabel(process);
74
+ this.logger.debug(`Unregistering process. ${processLabel}`);
75
+ if (!process.killed) {
76
+ this.logger.debug(`Ensuring process termination. ${processLabel}`);
77
+ process.kill();
78
+ }
79
+ if (this.processes.delete(process.id)) {
80
+ this.deleteEmitter.fire(process.id);
81
+ this.logger.debug(`The process was successfully unregistered. ${processLabel}`);
82
+ }
83
+ else {
84
+ this.logger.warn(`This process was not registered or was already unregistered. ${processLabel}`);
85
+ }
86
+ }
87
+ get(id) {
88
+ return this.processes.get(id);
89
+ }
90
+ get onDelete() {
91
+ return this.deleteEmitter.event;
92
+ }
93
+ onStop() {
94
+ for (const process of this.processes.values()) {
95
+ try {
96
+ this.unregister(process);
97
+ }
98
+ catch (error) {
99
+ this.logger.error(`Error occurred when unregistering process. ${this.getProcessLabel(process)}`, error);
100
+ }
101
+ }
102
+ }
103
+ getProcessLabel(process) {
104
+ return `[ID: ${process.id}]`;
105
+ }
106
+ };
107
+ ProcessManager = __decorate([
108
+ (0, inversify_1.injectable)(),
109
+ __param(0, (0, inversify_1.inject)(logger_1.ILogger)),
110
+ __param(0, (0, inversify_1.named)('process')),
111
+ __metadata("design:paramtypes", [Object])
112
+ ], ProcessManager);
113
+ exports.ProcessManager = ProcessManager;
114
114
  //# sourceMappingURL=process-manager.js.map
@@ -1,96 +1,96 @@
1
- /// <reference types="node" />
2
- import { ILogger, Emitter, Event } from '@theia/core/lib/common';
3
- import { Readable, Writable } from 'stream';
4
- import { IProcessStartEvent, IProcessExitEvent, ProcessErrorEvent, ProcessType, ManagedProcessManager, ManagedProcess } from '../common/process-manager-types';
5
- export { IProcessStartEvent, IProcessExitEvent, ProcessErrorEvent, ProcessType };
6
- /**
7
- * Options to spawn a new process (`spawn`).
8
- *
9
- * For more information please refer to the spawn function of Node's
10
- * child_process module:
11
- *
12
- * https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
13
- */
14
- export interface ProcessOptions {
15
- readonly command: string;
16
- args?: string[];
17
- options?: {
18
- [key: string]: any;
19
- };
20
- }
21
- /**
22
- * Options to fork a new process using the current Node interpreter (`fork`).
23
- *
24
- * For more information please refer to the fork function of Node's
25
- * child_process module:
26
- *
27
- * https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
28
- */
29
- export interface ForkOptions {
30
- readonly modulePath: string;
31
- args?: string[];
32
- options?: object;
33
- }
34
- export declare abstract class Process implements ManagedProcess {
35
- protected readonly processManager: ManagedProcessManager;
36
- protected readonly logger: ILogger;
37
- protected readonly type: ProcessType;
38
- protected readonly options: ProcessOptions | ForkOptions;
39
- readonly id: number;
40
- protected readonly startEmitter: Emitter<IProcessStartEvent>;
41
- protected readonly exitEmitter: Emitter<IProcessExitEvent>;
42
- protected readonly closeEmitter: Emitter<IProcessExitEvent>;
43
- protected readonly errorEmitter: Emitter<ProcessErrorEvent>;
44
- protected _killed: boolean;
45
- /**
46
- * The OS process id.
47
- */
48
- abstract readonly pid: number;
49
- /**
50
- * The stdout stream.
51
- */
52
- abstract readonly outputStream: Readable;
53
- /**
54
- * The stderr stream.
55
- */
56
- abstract readonly errorStream: Readable;
57
- /**
58
- * The stdin stream.
59
- */
60
- abstract readonly inputStream: Writable;
61
- constructor(processManager: ManagedProcessManager, logger: ILogger, type: ProcessType, options: ProcessOptions | ForkOptions);
62
- abstract kill(signal?: string): void;
63
- get killed(): boolean;
64
- get onStart(): Event<IProcessStartEvent>;
65
- /**
66
- * Wait for the process to exit, streams can still emit data.
67
- */
68
- get onExit(): Event<IProcessExitEvent>;
69
- get onError(): Event<ProcessErrorEvent>;
70
- /**
71
- * Waits for both process exit and for all the streams to be closed.
72
- */
73
- get onClose(): Event<IProcessExitEvent>;
74
- protected emitOnStarted(): void;
75
- /**
76
- * Emit the onExit event for this process. Only one of code and signal
77
- * should be defined.
78
- */
79
- protected emitOnExit(code?: number, signal?: string): void;
80
- /**
81
- * Emit the onClose event for this process. Only one of code and signal
82
- * should be defined.
83
- */
84
- protected emitOnClose(code?: number, signal?: string): void;
85
- protected handleOnExit(event: IProcessExitEvent): void;
86
- protected emitOnError(err: ProcessErrorEvent): void;
87
- protected emitOnErrorAsync(error: ProcessErrorEvent): Promise<void>;
88
- protected handleOnError(error: ProcessErrorEvent): void;
89
- protected isForkOptions(options: unknown): options is ForkOptions;
90
- protected readonly initialCwd: string;
91
- /**
92
- * @returns the current working directory as a URI (usually file:// URI)
93
- */
94
- getCwdURI(): Promise<string>;
95
- }
1
+ /// <reference types="node" />
2
+ import { ILogger, Emitter, Event } from '@theia/core/lib/common';
3
+ import { Readable, Writable } from 'stream';
4
+ import { IProcessStartEvent, IProcessExitEvent, ProcessErrorEvent, ProcessType, ManagedProcessManager, ManagedProcess } from '../common/process-manager-types';
5
+ export { IProcessStartEvent, IProcessExitEvent, ProcessErrorEvent, ProcessType };
6
+ /**
7
+ * Options to spawn a new process (`spawn`).
8
+ *
9
+ * For more information please refer to the spawn function of Node's
10
+ * child_process module:
11
+ *
12
+ * https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
13
+ */
14
+ export interface ProcessOptions {
15
+ readonly command: string;
16
+ args?: string[];
17
+ options?: {
18
+ [key: string]: any;
19
+ };
20
+ }
21
+ /**
22
+ * Options to fork a new process using the current Node interpreter (`fork`).
23
+ *
24
+ * For more information please refer to the fork function of Node's
25
+ * child_process module:
26
+ *
27
+ * https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
28
+ */
29
+ export interface ForkOptions {
30
+ readonly modulePath: string;
31
+ args?: string[];
32
+ options?: object;
33
+ }
34
+ export declare abstract class Process implements ManagedProcess {
35
+ protected readonly processManager: ManagedProcessManager;
36
+ protected readonly logger: ILogger;
37
+ protected readonly type: ProcessType;
38
+ protected readonly options: ProcessOptions | ForkOptions;
39
+ readonly id: number;
40
+ protected readonly startEmitter: Emitter<IProcessStartEvent>;
41
+ protected readonly exitEmitter: Emitter<IProcessExitEvent>;
42
+ protected readonly closeEmitter: Emitter<IProcessExitEvent>;
43
+ protected readonly errorEmitter: Emitter<ProcessErrorEvent>;
44
+ protected _killed: boolean;
45
+ /**
46
+ * The OS process id.
47
+ */
48
+ abstract readonly pid: number;
49
+ /**
50
+ * The stdout stream.
51
+ */
52
+ abstract readonly outputStream: Readable;
53
+ /**
54
+ * The stderr stream.
55
+ */
56
+ abstract readonly errorStream: Readable;
57
+ /**
58
+ * The stdin stream.
59
+ */
60
+ abstract readonly inputStream: Writable;
61
+ constructor(processManager: ManagedProcessManager, logger: ILogger, type: ProcessType, options: ProcessOptions | ForkOptions);
62
+ abstract kill(signal?: string): void;
63
+ get killed(): boolean;
64
+ get onStart(): Event<IProcessStartEvent>;
65
+ /**
66
+ * Wait for the process to exit, streams can still emit data.
67
+ */
68
+ get onExit(): Event<IProcessExitEvent>;
69
+ get onError(): Event<ProcessErrorEvent>;
70
+ /**
71
+ * Waits for both process exit and for all the streams to be closed.
72
+ */
73
+ get onClose(): Event<IProcessExitEvent>;
74
+ protected emitOnStarted(): void;
75
+ /**
76
+ * Emit the onExit event for this process. Only one of code and signal
77
+ * should be defined.
78
+ */
79
+ protected emitOnExit(code?: number, signal?: string): void;
80
+ /**
81
+ * Emit the onClose event for this process. Only one of code and signal
82
+ * should be defined.
83
+ */
84
+ protected emitOnClose(code?: number, signal?: string): void;
85
+ protected handleOnExit(event: IProcessExitEvent): void;
86
+ protected emitOnError(err: ProcessErrorEvent): void;
87
+ protected emitOnErrorAsync(error: ProcessErrorEvent): Promise<void>;
88
+ protected handleOnError(error: ProcessErrorEvent): void;
89
+ protected isForkOptions(options: unknown): options is ForkOptions;
90
+ protected readonly initialCwd: string;
91
+ /**
92
+ * @returns the current working directory as a URI (usually file:// URI)
93
+ */
94
+ getCwdURI(): Promise<string>;
95
+ }
96
96
  //# sourceMappingURL=process.d.ts.map