@theia/process 1.53.0-next.4 → 1.53.0-next.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/lib/common/shell-command-builder.slow-spec.js +4 -4
- package/package.json +4 -4
- package/src/common/process-common-module.ts +22 -22
- package/src/common/process-manager-types.ts +58 -58
- package/src/common/shell-command-builder.slow-spec.ts +486 -486
- package/src/common/shell-command-builder.ts +187 -187
- package/src/common/shell-quoting.spec.ts +176 -176
- package/src/common/shell-quoting.ts +236 -236
- package/src/common/tests/$weird(),file=name.js +1 -1
- package/src/common/tests/white space.js +1 -1
- package/src/node/dev-null-stream.ts +47 -47
- package/src/node/index.ts +22 -22
- package/src/node/multi-ring-buffer.spec.ts +486 -486
- package/src/node/multi-ring-buffer.ts +348 -348
- package/src/node/process-backend-module.ts +67 -67
- package/src/node/process-manager.ts +107 -107
- package/src/node/process.ts +207 -207
- package/src/node/pseudo-pty.ts +56 -56
- package/src/node/raw-process.spec.ts +199 -199
- package/src/node/raw-process.ts +156 -156
- package/src/node/string-argv.d.ts +21 -21
- package/src/node/task-terminal-process.ts +41 -41
- package/src/node/terminal-process.spec.ts +121 -121
- package/src/node/terminal-process.ts +290 -290
- package/src/node/test/process-fork-test.js +22 -22
- package/src/node/test/process-test-container.ts +27 -27
- package/src/node/utils.ts +79 -79
package/src/node/process.ts
CHANGED
|
@@ -1,207 +1,207 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2017 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, unmanaged } from '@theia/core/shared/inversify';
|
|
18
|
-
import { ILogger, Emitter, Event, isObject } from '@theia/core/lib/common';
|
|
19
|
-
import { FileUri } from '@theia/core/lib/node';
|
|
20
|
-
import { isOSX, isWindows } from '@theia/core';
|
|
21
|
-
import { Readable, Writable } from 'stream';
|
|
22
|
-
import { exec } from 'child_process';
|
|
23
|
-
import * as fs from 'fs';
|
|
24
|
-
import { IProcessStartEvent, IProcessExitEvent, ProcessErrorEvent, ProcessType, ManagedProcessManager, ManagedProcess } from '../common/process-manager-types';
|
|
25
|
-
export { IProcessStartEvent, IProcessExitEvent, ProcessErrorEvent, ProcessType };
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Options to spawn a new process (`spawn`).
|
|
29
|
-
*
|
|
30
|
-
* For more information please refer to the spawn function of Node's
|
|
31
|
-
* child_process module:
|
|
32
|
-
*
|
|
33
|
-
* https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
|
|
34
|
-
*/
|
|
35
|
-
export interface ProcessOptions {
|
|
36
|
-
readonly command: string,
|
|
37
|
-
args?: string[],
|
|
38
|
-
options?: {
|
|
39
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
-
[key: string]: any
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Options to fork a new process using the current Node interpreter (`fork`).
|
|
46
|
-
*
|
|
47
|
-
* For more information please refer to the fork function of Node's
|
|
48
|
-
* child_process module:
|
|
49
|
-
*
|
|
50
|
-
* https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
|
|
51
|
-
*/
|
|
52
|
-
export interface ForkOptions {
|
|
53
|
-
readonly modulePath: string,
|
|
54
|
-
args?: string[],
|
|
55
|
-
options?: object
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
@injectable()
|
|
59
|
-
export abstract class Process implements ManagedProcess {
|
|
60
|
-
|
|
61
|
-
readonly id: number;
|
|
62
|
-
protected readonly startEmitter: Emitter<IProcessStartEvent> = new Emitter<IProcessStartEvent>();
|
|
63
|
-
protected readonly exitEmitter: Emitter<IProcessExitEvent> = new Emitter<IProcessExitEvent>();
|
|
64
|
-
protected readonly closeEmitter: Emitter<IProcessExitEvent> = new Emitter<IProcessExitEvent>();
|
|
65
|
-
protected readonly errorEmitter: Emitter<ProcessErrorEvent> = new Emitter<ProcessErrorEvent>();
|
|
66
|
-
protected _killed = false;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* The OS process id.
|
|
70
|
-
*/
|
|
71
|
-
abstract readonly pid: number;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* The stdout stream.
|
|
75
|
-
*/
|
|
76
|
-
abstract readonly outputStream: Readable;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* The stderr stream.
|
|
80
|
-
*/
|
|
81
|
-
abstract readonly errorStream: Readable;
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* The stdin stream.
|
|
85
|
-
*/
|
|
86
|
-
abstract readonly inputStream: Writable;
|
|
87
|
-
|
|
88
|
-
constructor(
|
|
89
|
-
protected readonly processManager: ManagedProcessManager,
|
|
90
|
-
protected readonly logger: ILogger,
|
|
91
|
-
@unmanaged() protected readonly type: ProcessType,
|
|
92
|
-
protected readonly options: ProcessOptions | ForkOptions
|
|
93
|
-
) {
|
|
94
|
-
this.id = this.processManager.register(this);
|
|
95
|
-
this.initialCwd = options && options.options && 'cwd' in options.options && options.options['cwd'].toString() || __dirname;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
abstract kill(signal?: string): void;
|
|
99
|
-
|
|
100
|
-
get killed(): boolean {
|
|
101
|
-
return this._killed;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
get onStart(): Event<IProcessStartEvent> {
|
|
105
|
-
return this.startEmitter.event;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Wait for the process to exit, streams can still emit data.
|
|
110
|
-
*/
|
|
111
|
-
get onExit(): Event<IProcessExitEvent> {
|
|
112
|
-
return this.exitEmitter.event;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
get onError(): Event<ProcessErrorEvent> {
|
|
116
|
-
return this.errorEmitter.event;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Waits for both process exit and for all the streams to be closed.
|
|
121
|
-
*/
|
|
122
|
-
get onClose(): Event<IProcessExitEvent> {
|
|
123
|
-
return this.closeEmitter.event;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
protected emitOnStarted(): void {
|
|
127
|
-
this.startEmitter.fire({});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Emit the onExit event for this process. Only one of code and signal
|
|
132
|
-
* should be defined.
|
|
133
|
-
*/
|
|
134
|
-
protected emitOnExit(code?: number, signal?: string): void {
|
|
135
|
-
const exitEvent: IProcessExitEvent = { code, signal };
|
|
136
|
-
this.handleOnExit(exitEvent);
|
|
137
|
-
this.exitEmitter.fire(exitEvent);
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Emit the onClose event for this process. Only one of code and signal
|
|
142
|
-
* should be defined.
|
|
143
|
-
*/
|
|
144
|
-
protected emitOnClose(code?: number, signal?: string): void {
|
|
145
|
-
this.closeEmitter.fire({ code, signal });
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
protected handleOnExit(event: IProcessExitEvent): void {
|
|
149
|
-
this._killed = true;
|
|
150
|
-
const signalSuffix = event.signal ? `, signal: ${event.signal}` : '';
|
|
151
|
-
const executable = this.isForkOptions(this.options) ? this.options.modulePath : this.options.command;
|
|
152
|
-
|
|
153
|
-
this.logger.debug(`Process ${this.pid} has exited with code ${event.code}${signalSuffix}.`,
|
|
154
|
-
executable, this.options.args);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
protected emitOnError(err: ProcessErrorEvent): void {
|
|
158
|
-
this.handleOnError(err);
|
|
159
|
-
this.errorEmitter.fire(err);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
protected async emitOnErrorAsync(error: ProcessErrorEvent): Promise<void> {
|
|
163
|
-
process.nextTick(this.emitOnError.bind(this), error);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
protected handleOnError(error: ProcessErrorEvent): void {
|
|
167
|
-
this._killed = true;
|
|
168
|
-
this.logger.error(error);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
protected isForkOptions(options: unknown): options is ForkOptions {
|
|
172
|
-
return isObject<ForkOptions>(options) && !!options.modulePath;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
protected readonly initialCwd: string;
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* @returns the current working directory as a URI (usually file:// URI)
|
|
179
|
-
*/
|
|
180
|
-
public getCwdURI(): Promise<string> {
|
|
181
|
-
if (isOSX) {
|
|
182
|
-
return new Promise<string>(resolve => {
|
|
183
|
-
exec('lsof -OPln -p ' + this.pid + ' | grep cwd', (error, stdout, stderr) => {
|
|
184
|
-
if (stdout !== '') {
|
|
185
|
-
resolve(FileUri.create(stdout.substring(stdout.indexOf('/'), stdout.length - 1)).toString());
|
|
186
|
-
} else {
|
|
187
|
-
resolve(FileUri.create(this.initialCwd).toString());
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
} else if (!isWindows) {
|
|
192
|
-
return new Promise<string>(resolve => {
|
|
193
|
-
fs.readlink('/proc/' + this.pid + '/cwd', (err, linkedstr) => {
|
|
194
|
-
if (err || !linkedstr) {
|
|
195
|
-
resolve(FileUri.create(this.initialCwd).toString());
|
|
196
|
-
} else {
|
|
197
|
-
resolve(FileUri.create(linkedstr).toString());
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
} else {
|
|
202
|
-
return new Promise<string>(resolve => {
|
|
203
|
-
resolve(FileUri.create(this.initialCwd).toString());
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 Ericsson and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { injectable, unmanaged } from '@theia/core/shared/inversify';
|
|
18
|
+
import { ILogger, Emitter, Event, isObject } from '@theia/core/lib/common';
|
|
19
|
+
import { FileUri } from '@theia/core/lib/node';
|
|
20
|
+
import { isOSX, isWindows } from '@theia/core';
|
|
21
|
+
import { Readable, Writable } from 'stream';
|
|
22
|
+
import { exec } from 'child_process';
|
|
23
|
+
import * as fs from 'fs';
|
|
24
|
+
import { IProcessStartEvent, IProcessExitEvent, ProcessErrorEvent, ProcessType, ManagedProcessManager, ManagedProcess } from '../common/process-manager-types';
|
|
25
|
+
export { IProcessStartEvent, IProcessExitEvent, ProcessErrorEvent, ProcessType };
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Options to spawn a new process (`spawn`).
|
|
29
|
+
*
|
|
30
|
+
* For more information please refer to the spawn function of Node's
|
|
31
|
+
* child_process module:
|
|
32
|
+
*
|
|
33
|
+
* https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options
|
|
34
|
+
*/
|
|
35
|
+
export interface ProcessOptions {
|
|
36
|
+
readonly command: string,
|
|
37
|
+
args?: string[],
|
|
38
|
+
options?: {
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
|
+
[key: string]: any
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Options to fork a new process using the current Node interpreter (`fork`).
|
|
46
|
+
*
|
|
47
|
+
* For more information please refer to the fork function of Node's
|
|
48
|
+
* child_process module:
|
|
49
|
+
*
|
|
50
|
+
* https://nodejs.org/api/child_process.html#child_process_child_process_fork_modulepath_args_options
|
|
51
|
+
*/
|
|
52
|
+
export interface ForkOptions {
|
|
53
|
+
readonly modulePath: string,
|
|
54
|
+
args?: string[],
|
|
55
|
+
options?: object
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@injectable()
|
|
59
|
+
export abstract class Process implements ManagedProcess {
|
|
60
|
+
|
|
61
|
+
readonly id: number;
|
|
62
|
+
protected readonly startEmitter: Emitter<IProcessStartEvent> = new Emitter<IProcessStartEvent>();
|
|
63
|
+
protected readonly exitEmitter: Emitter<IProcessExitEvent> = new Emitter<IProcessExitEvent>();
|
|
64
|
+
protected readonly closeEmitter: Emitter<IProcessExitEvent> = new Emitter<IProcessExitEvent>();
|
|
65
|
+
protected readonly errorEmitter: Emitter<ProcessErrorEvent> = new Emitter<ProcessErrorEvent>();
|
|
66
|
+
protected _killed = false;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The OS process id.
|
|
70
|
+
*/
|
|
71
|
+
abstract readonly pid: number;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* The stdout stream.
|
|
75
|
+
*/
|
|
76
|
+
abstract readonly outputStream: Readable;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The stderr stream.
|
|
80
|
+
*/
|
|
81
|
+
abstract readonly errorStream: Readable;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The stdin stream.
|
|
85
|
+
*/
|
|
86
|
+
abstract readonly inputStream: Writable;
|
|
87
|
+
|
|
88
|
+
constructor(
|
|
89
|
+
protected readonly processManager: ManagedProcessManager,
|
|
90
|
+
protected readonly logger: ILogger,
|
|
91
|
+
@unmanaged() protected readonly type: ProcessType,
|
|
92
|
+
protected readonly options: ProcessOptions | ForkOptions
|
|
93
|
+
) {
|
|
94
|
+
this.id = this.processManager.register(this);
|
|
95
|
+
this.initialCwd = options && options.options && 'cwd' in options.options && options.options['cwd'].toString() || __dirname;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
abstract kill(signal?: string): void;
|
|
99
|
+
|
|
100
|
+
get killed(): boolean {
|
|
101
|
+
return this._killed;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get onStart(): Event<IProcessStartEvent> {
|
|
105
|
+
return this.startEmitter.event;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Wait for the process to exit, streams can still emit data.
|
|
110
|
+
*/
|
|
111
|
+
get onExit(): Event<IProcessExitEvent> {
|
|
112
|
+
return this.exitEmitter.event;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get onError(): Event<ProcessErrorEvent> {
|
|
116
|
+
return this.errorEmitter.event;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Waits for both process exit and for all the streams to be closed.
|
|
121
|
+
*/
|
|
122
|
+
get onClose(): Event<IProcessExitEvent> {
|
|
123
|
+
return this.closeEmitter.event;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
protected emitOnStarted(): void {
|
|
127
|
+
this.startEmitter.fire({});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Emit the onExit event for this process. Only one of code and signal
|
|
132
|
+
* should be defined.
|
|
133
|
+
*/
|
|
134
|
+
protected emitOnExit(code?: number, signal?: string): void {
|
|
135
|
+
const exitEvent: IProcessExitEvent = { code, signal };
|
|
136
|
+
this.handleOnExit(exitEvent);
|
|
137
|
+
this.exitEmitter.fire(exitEvent);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Emit the onClose event for this process. Only one of code and signal
|
|
142
|
+
* should be defined.
|
|
143
|
+
*/
|
|
144
|
+
protected emitOnClose(code?: number, signal?: string): void {
|
|
145
|
+
this.closeEmitter.fire({ code, signal });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
protected handleOnExit(event: IProcessExitEvent): void {
|
|
149
|
+
this._killed = true;
|
|
150
|
+
const signalSuffix = event.signal ? `, signal: ${event.signal}` : '';
|
|
151
|
+
const executable = this.isForkOptions(this.options) ? this.options.modulePath : this.options.command;
|
|
152
|
+
|
|
153
|
+
this.logger.debug(`Process ${this.pid} has exited with code ${event.code}${signalSuffix}.`,
|
|
154
|
+
executable, this.options.args);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
protected emitOnError(err: ProcessErrorEvent): void {
|
|
158
|
+
this.handleOnError(err);
|
|
159
|
+
this.errorEmitter.fire(err);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
protected async emitOnErrorAsync(error: ProcessErrorEvent): Promise<void> {
|
|
163
|
+
process.nextTick(this.emitOnError.bind(this), error);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
protected handleOnError(error: ProcessErrorEvent): void {
|
|
167
|
+
this._killed = true;
|
|
168
|
+
this.logger.error(error);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
protected isForkOptions(options: unknown): options is ForkOptions {
|
|
172
|
+
return isObject<ForkOptions>(options) && !!options.modulePath;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
protected readonly initialCwd: string;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @returns the current working directory as a URI (usually file:// URI)
|
|
179
|
+
*/
|
|
180
|
+
public getCwdURI(): Promise<string> {
|
|
181
|
+
if (isOSX) {
|
|
182
|
+
return new Promise<string>(resolve => {
|
|
183
|
+
exec('lsof -OPln -p ' + this.pid + ' | grep cwd', (error, stdout, stderr) => {
|
|
184
|
+
if (stdout !== '') {
|
|
185
|
+
resolve(FileUri.create(stdout.substring(stdout.indexOf('/'), stdout.length - 1)).toString());
|
|
186
|
+
} else {
|
|
187
|
+
resolve(FileUri.create(this.initialCwd).toString());
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
} else if (!isWindows) {
|
|
192
|
+
return new Promise<string>(resolve => {
|
|
193
|
+
fs.readlink('/proc/' + this.pid + '/cwd', (err, linkedstr) => {
|
|
194
|
+
if (err || !linkedstr) {
|
|
195
|
+
resolve(FileUri.create(this.initialCwd).toString());
|
|
196
|
+
} else {
|
|
197
|
+
resolve(FileUri.create(linkedstr).toString());
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
} else {
|
|
202
|
+
return new Promise<string>(resolve => {
|
|
203
|
+
resolve(FileUri.create(this.initialCwd).toString());
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
package/src/node/pseudo-pty.ts
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 Alibaba Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { IPty } from 'node-pty';
|
|
18
|
-
import { Event } from '@theia/core';
|
|
19
|
-
|
|
20
|
-
export class PseudoPty implements IPty {
|
|
21
|
-
|
|
22
|
-
readonly pid: number = -1;
|
|
23
|
-
|
|
24
|
-
readonly cols: number = -1;
|
|
25
|
-
|
|
26
|
-
readonly rows: number = -1;
|
|
27
|
-
|
|
28
|
-
readonly process: string = '';
|
|
29
|
-
|
|
30
|
-
handleFlowControl = false;
|
|
31
|
-
|
|
32
|
-
readonly onData: Event<string> = Event.None;
|
|
33
|
-
|
|
34
|
-
readonly onExit: Event<{ exitCode: number, signal?: number }> = Event.None;
|
|
35
|
-
|
|
36
|
-
on(event: string, listener: (data: string) => void): void;
|
|
37
|
-
|
|
38
|
-
on(event: string, listener: (exitCode: number, signal?: number) => void): void;
|
|
39
|
-
|
|
40
|
-
on(event: string, listener: (error?: string) => void): void;
|
|
41
|
-
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
-
on(event: string, listener: (...args: any[]) => void): void { }
|
|
44
|
-
|
|
45
|
-
resize(columns: number, rows: number): void { }
|
|
46
|
-
|
|
47
|
-
write(data: string): void { }
|
|
48
|
-
|
|
49
|
-
kill(signal?: string): void { }
|
|
50
|
-
|
|
51
|
-
pause(): void { }
|
|
52
|
-
|
|
53
|
-
resume(): void { }
|
|
54
|
-
|
|
55
|
-
clear(): void { }
|
|
56
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2020 Alibaba Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { IPty } from 'node-pty';
|
|
18
|
+
import { Event } from '@theia/core';
|
|
19
|
+
|
|
20
|
+
export class PseudoPty implements IPty {
|
|
21
|
+
|
|
22
|
+
readonly pid: number = -1;
|
|
23
|
+
|
|
24
|
+
readonly cols: number = -1;
|
|
25
|
+
|
|
26
|
+
readonly rows: number = -1;
|
|
27
|
+
|
|
28
|
+
readonly process: string = '';
|
|
29
|
+
|
|
30
|
+
handleFlowControl = false;
|
|
31
|
+
|
|
32
|
+
readonly onData: Event<string> = Event.None;
|
|
33
|
+
|
|
34
|
+
readonly onExit: Event<{ exitCode: number, signal?: number }> = Event.None;
|
|
35
|
+
|
|
36
|
+
on(event: string, listener: (data: string) => void): void;
|
|
37
|
+
|
|
38
|
+
on(event: string, listener: (exitCode: number, signal?: number) => void): void;
|
|
39
|
+
|
|
40
|
+
on(event: string, listener: (error?: string) => void): void;
|
|
41
|
+
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43
|
+
on(event: string, listener: (...args: any[]) => void): void { }
|
|
44
|
+
|
|
45
|
+
resize(columns: number, rows: number): void { }
|
|
46
|
+
|
|
47
|
+
write(data: string): void { }
|
|
48
|
+
|
|
49
|
+
kill(signal?: string): void { }
|
|
50
|
+
|
|
51
|
+
pause(): void { }
|
|
52
|
+
|
|
53
|
+
resume(): void { }
|
|
54
|
+
|
|
55
|
+
clear(): void { }
|
|
56
|
+
}
|