@theia/process 1.48.1 → 1.48.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 (69) hide show
  1. package/README.md +30 -30
  2. package/lib/common/process-common-module.d.ts +3 -3
  3. package/lib/common/process-common-module.js +22 -22
  4. package/lib/common/process-manager-types.d.ts +35 -35
  5. package/lib/common/process-manager-types.js +23 -23
  6. package/lib/common/shell-command-builder.d.ts +49 -49
  7. package/lib/common/shell-command-builder.js +169 -169
  8. package/lib/common/shell-command-builder.slow-spec.d.ts +9 -9
  9. package/lib/common/shell-command-builder.slow-spec.js +404 -404
  10. package/lib/common/shell-quoting.d.ts +91 -91
  11. package/lib/common/shell-quoting.js +145 -145
  12. package/lib/common/shell-quoting.spec.d.ts +1 -1
  13. package/lib/common/shell-quoting.spec.js +170 -170
  14. package/lib/node/dev-null-stream.d.ts +17 -17
  15. package/lib/node/dev-null-stream.js +41 -41
  16. package/lib/node/index.d.ts +6 -6
  17. package/lib/node/index.js +24 -24
  18. package/lib/node/multi-ring-buffer.d.ts +68 -68
  19. package/lib/node/multi-ring-buffer.js +299 -299
  20. package/lib/node/multi-ring-buffer.spec.d.ts +1 -1
  21. package/lib/node/multi-ring-buffer.spec.js +422 -422
  22. package/lib/node/process-backend-module.d.ts +3 -3
  23. package/lib/node/process-backend-module.js +56 -56
  24. package/lib/node/process-manager.d.ts +33 -33
  25. package/lib/node/process-manager.js +102 -102
  26. package/lib/node/process.d.ts +95 -95
  27. package/lib/node/process.js +142 -142
  28. package/lib/node/pseudo-pty.d.ts +22 -22
  29. package/lib/node/pseudo-pty.js +38 -38
  30. package/lib/node/raw-process.d.ts +45 -45
  31. package/lib/node/raw-process.js +104 -104
  32. package/lib/node/raw-process.spec.d.ts +1 -1
  33. package/lib/node/raw-process.spec.js +164 -164
  34. package/lib/node/task-terminal-process.d.ts +10 -10
  35. package/lib/node/task-terminal-process.js +42 -42
  36. package/lib/node/terminal-process.d.ts +60 -60
  37. package/lib/node/terminal-process.js +248 -248
  38. package/lib/node/terminal-process.spec.d.ts +1 -1
  39. package/lib/node/terminal-process.spec.js +103 -103
  40. package/lib/node/test/process-test-container.d.ts +2 -2
  41. package/lib/node/test/process-test-container.js +28 -28
  42. package/lib/node/utils.d.ts +16 -16
  43. package/lib/node/utils.js +77 -77
  44. package/package.json +4 -4
  45. package/src/common/process-common-module.ts +22 -22
  46. package/src/common/process-manager-types.ts +58 -58
  47. package/src/common/shell-command-builder.slow-spec.ts +486 -486
  48. package/src/common/shell-command-builder.ts +187 -187
  49. package/src/common/shell-quoting.spec.ts +176 -176
  50. package/src/common/shell-quoting.ts +236 -236
  51. package/src/common/tests/$weird(),file=name.js +1 -1
  52. package/src/common/tests/white space.js +1 -1
  53. package/src/node/dev-null-stream.ts +47 -47
  54. package/src/node/index.ts +22 -22
  55. package/src/node/multi-ring-buffer.spec.ts +486 -486
  56. package/src/node/multi-ring-buffer.ts +348 -348
  57. package/src/node/process-backend-module.ts +67 -67
  58. package/src/node/process-manager.ts +107 -107
  59. package/src/node/process.ts +207 -207
  60. package/src/node/pseudo-pty.ts +54 -54
  61. package/src/node/raw-process.spec.ts +199 -199
  62. package/src/node/raw-process.ts +156 -156
  63. package/src/node/string-argv.d.ts +21 -21
  64. package/src/node/task-terminal-process.ts +41 -41
  65. package/src/node/terminal-process.spec.ts +121 -121
  66. package/src/node/terminal-process.ts +290 -290
  67. package/src/node/test/process-fork-test.js +22 -22
  68. package/src/node/test/process-test-container.ts +27 -27
  69. 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-only 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-only 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,103 +1,103 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProcessManager = void 0;
4
- const tslib_1 = require("tslib");
5
- // *****************************************************************************
6
- // Copyright (C) 2017 Ericsson and others.
7
- //
8
- // This program and the accompanying materials are made available under the
9
- // terms of the Eclipse Public License v. 2.0 which is available at
10
- // http://www.eclipse.org/legal/epl-2.0.
11
- //
12
- // This Source Code may also be made available under the following Secondary
13
- // Licenses when the conditions for such availability set forth in the Eclipse
14
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
15
- // with the GNU Classpath Exception which is available at
16
- // https://www.gnu.org/software/classpath/license.html.
17
- //
18
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
19
- // *****************************************************************************
20
- const inversify_1 = require("@theia/core/shared/inversify");
21
- const common_1 = require("@theia/core/lib/common");
22
- const logger_1 = require("@theia/core/lib/common/logger");
23
- const numbers_1 = require("@theia/core/lib/common/numbers");
24
- let ProcessManager = class ProcessManager {
25
- constructor(logger) {
26
- this.logger = logger;
27
- this.processes = new Map();
28
- this.deleteEmitter = new common_1.Emitter();
29
- }
30
- /**
31
- * Registers the given process into this manager. Both on process termination and on error,
32
- * the process will be automatically removed from the manager.
33
- *
34
- * @param process the process to register.
35
- */
36
- register(process) {
37
- const id = this.generateId();
38
- this.processes.set(id, process);
39
- process.onError(() => this.unregister(process));
40
- return id;
41
- }
42
- /**
43
- * @returns a random id for a process that is not assigned to a different process yet.
44
- */
45
- generateId() {
46
- let id = undefined;
47
- while (id === undefined) {
48
- const candidate = Math.floor(Math.random() * numbers_1.MAX_SAFE_INTEGER);
49
- if (!this.processes.has(candidate)) {
50
- id = candidate;
51
- }
52
- }
53
- return id;
54
- }
55
- /**
56
- * Removes the process from this process manager. Invoking this method, will make
57
- * sure that the process is terminated before eliminating it from the manager's cache.
58
- *
59
- * @param process the process to unregister from this process manager.
60
- */
61
- unregister(process) {
62
- const processLabel = this.getProcessLabel(process);
63
- this.logger.debug(`Unregistering process. ${processLabel}`);
64
- if (!process.killed) {
65
- this.logger.debug(`Ensuring process termination. ${processLabel}`);
66
- process.kill();
67
- }
68
- if (this.processes.delete(process.id)) {
69
- this.deleteEmitter.fire(process.id);
70
- this.logger.debug(`The process was successfully unregistered. ${processLabel}`);
71
- }
72
- else {
73
- this.logger.warn(`This process was not registered or was already unregistered. ${processLabel}`);
74
- }
75
- }
76
- get(id) {
77
- return this.processes.get(id);
78
- }
79
- get onDelete() {
80
- return this.deleteEmitter.event;
81
- }
82
- onStop() {
83
- for (const process of this.processes.values()) {
84
- try {
85
- this.unregister(process);
86
- }
87
- catch (error) {
88
- this.logger.error(`Error occurred when unregistering process. ${this.getProcessLabel(process)}`, error);
89
- }
90
- }
91
- }
92
- getProcessLabel(process) {
93
- return `[ID: ${process.id}]`;
94
- }
95
- };
96
- ProcessManager = (0, tslib_1.__decorate)([
97
- (0, inversify_1.injectable)(),
98
- (0, tslib_1.__param)(0, (0, inversify_1.inject)(logger_1.ILogger)),
99
- (0, tslib_1.__param)(0, (0, inversify_1.named)('process')),
100
- (0, tslib_1.__metadata)("design:paramtypes", [Object])
101
- ], ProcessManager);
102
- exports.ProcessManager = ProcessManager;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProcessManager = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // *****************************************************************************
6
+ // Copyright (C) 2017 Ericsson and others.
7
+ //
8
+ // This program and the accompanying materials are made available under the
9
+ // terms of the Eclipse Public License v. 2.0 which is available at
10
+ // http://www.eclipse.org/legal/epl-2.0.
11
+ //
12
+ // This Source Code may also be made available under the following Secondary
13
+ // Licenses when the conditions for such availability set forth in the Eclipse
14
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
15
+ // with the GNU Classpath Exception which is available at
16
+ // https://www.gnu.org/software/classpath/license.html.
17
+ //
18
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
19
+ // *****************************************************************************
20
+ const inversify_1 = require("@theia/core/shared/inversify");
21
+ const common_1 = require("@theia/core/lib/common");
22
+ const logger_1 = require("@theia/core/lib/common/logger");
23
+ const numbers_1 = require("@theia/core/lib/common/numbers");
24
+ let ProcessManager = class ProcessManager {
25
+ constructor(logger) {
26
+ this.logger = logger;
27
+ this.processes = new Map();
28
+ this.deleteEmitter = new common_1.Emitter();
29
+ }
30
+ /**
31
+ * Registers the given process into this manager. Both on process termination and on error,
32
+ * the process will be automatically removed from the manager.
33
+ *
34
+ * @param process the process to register.
35
+ */
36
+ register(process) {
37
+ const id = this.generateId();
38
+ this.processes.set(id, process);
39
+ process.onError(() => this.unregister(process));
40
+ return id;
41
+ }
42
+ /**
43
+ * @returns a random id for a process that is not assigned to a different process yet.
44
+ */
45
+ generateId() {
46
+ let id = undefined;
47
+ while (id === undefined) {
48
+ const candidate = Math.floor(Math.random() * numbers_1.MAX_SAFE_INTEGER);
49
+ if (!this.processes.has(candidate)) {
50
+ id = candidate;
51
+ }
52
+ }
53
+ return id;
54
+ }
55
+ /**
56
+ * Removes the process from this process manager. Invoking this method, will make
57
+ * sure that the process is terminated before eliminating it from the manager's cache.
58
+ *
59
+ * @param process the process to unregister from this process manager.
60
+ */
61
+ unregister(process) {
62
+ const processLabel = this.getProcessLabel(process);
63
+ this.logger.debug(`Unregistering process. ${processLabel}`);
64
+ if (!process.killed) {
65
+ this.logger.debug(`Ensuring process termination. ${processLabel}`);
66
+ process.kill();
67
+ }
68
+ if (this.processes.delete(process.id)) {
69
+ this.deleteEmitter.fire(process.id);
70
+ this.logger.debug(`The process was successfully unregistered. ${processLabel}`);
71
+ }
72
+ else {
73
+ this.logger.warn(`This process was not registered or was already unregistered. ${processLabel}`);
74
+ }
75
+ }
76
+ get(id) {
77
+ return this.processes.get(id);
78
+ }
79
+ get onDelete() {
80
+ return this.deleteEmitter.event;
81
+ }
82
+ onStop() {
83
+ for (const process of this.processes.values()) {
84
+ try {
85
+ this.unregister(process);
86
+ }
87
+ catch (error) {
88
+ this.logger.error(`Error occurred when unregistering process. ${this.getProcessLabel(process)}`, error);
89
+ }
90
+ }
91
+ }
92
+ getProcessLabel(process) {
93
+ return `[ID: ${process.id}]`;
94
+ }
95
+ };
96
+ ProcessManager = (0, tslib_1.__decorate)([
97
+ (0, inversify_1.injectable)(),
98
+ (0, tslib_1.__param)(0, (0, inversify_1.inject)(logger_1.ILogger)),
99
+ (0, tslib_1.__param)(0, (0, inversify_1.named)('process')),
100
+ (0, tslib_1.__metadata)("design:paramtypes", [Object])
101
+ ], ProcessManager);
102
+ exports.ProcessManager = ProcessManager;
103
103
  //# 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