@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.
@@ -1,236 +1,236 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2020 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
- // #region vscode
18
-
19
- /*---------------------------------------------------------------------------------------------
20
- * Copyright (c) Microsoft Corporation. All rights reserved.
21
- * Licensed under the MIT License. See License.txt in the project root for license information.
22
- *--------------------------------------------------------------------------------------------*/
23
-
24
- // See: https://github.com/microsoft/vscode/blob/9ebb7c43bc99fd6e1a295040674d1f8e5831b9be/src/vs/vscode.d.ts#L5326-L5370
25
-
26
- /**
27
- * Defines how an argument should be quoted if it contains
28
- * spaces or unsupported characters.
29
- */
30
- export const enum ShellQuoting {
31
-
32
- /**
33
- * Character escaping should be used. This for example
34
- * uses \ on bash and ` on PowerShell.
35
- */
36
- Escape = 'escape',
37
-
38
- /**
39
- * Strong string quoting should be used. This for example
40
- * uses " for Windows cmd and ' for bash and PowerShell.
41
- * Strong quoting treats arguments as literal strings.
42
- * Under PowerShell echo 'The value is $(2 * 3)' will
43
- * print `The value is $(2 * 3)`
44
- */
45
- Strong = 'strong',
46
-
47
- /**
48
- * Weak string quoting should be used. This for example
49
- * uses " for Windows cmd, bash and PowerShell. Weak quoting
50
- * still performs some kind of evaluation inside the quoted
51
- * string. Under PowerShell echo "The value is $(2 * 3)"
52
- * will print `The value is 6`
53
- */
54
- Weak = 'weak'
55
- }
56
-
57
- /**
58
- * A string that will be quoted depending on the used shell.
59
- */
60
- export interface ShellQuotedString {
61
- /**
62
- * The actual string value.
63
- */
64
- value: string;
65
-
66
- /**
67
- * The quoting style to use.
68
- */
69
- quoting: ShellQuoting;
70
- }
71
-
72
- // #endregion vscode
73
-
74
- /**
75
- * Functions that provide shell quoting capabilities.
76
- */
77
- export interface ShellQuotingFunctions {
78
-
79
- characters: {
80
- /** Characters that require quotes, white space is always implied. */
81
- needQuotes?: string
82
- /** The character used to escape sequences. */
83
- escape?: string
84
- /** The character used to quote sequences, preventing variable expansion. */
85
- strong?: string
86
- /** The character used to quote sequences, allowing variable expansion. */
87
- weak?: string
88
- }
89
-
90
- /**
91
- * Should add escape-characters in front of forbidden characters.
92
- */
93
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
- escape?(this: any, arg: string): string
95
-
96
- /**
97
- * Should quote the argument in such a way that variables CANNOT be expanded.
98
- */
99
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
- strong?(this: any, arg: string): string;
101
-
102
- /**
103
- * Should quote the argument in such a way that variables CAN be expanded.
104
- */
105
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
- weak?(this: any, arg: string): string;
107
- }
108
-
109
- /**
110
- * Converts a list of args into an escaped shell command.
111
- *
112
- * There are two main use cases when handling command/arguments for a shell:
113
- * 1. User already wrote the escaped commandline, then just use that.
114
- * 2. User wants a specific process to be invoked with some arguments.
115
- *
116
- * The `createShellCommandLine` function is useful for the latter.
117
- *
118
- * @param args Standard list of spawn/exec arguments, first item is the command.
119
- * @param quotingFunctions Collection of functions to process arguments.
120
- */
121
- export function createShellCommandLine(args: Array<string | ShellQuotedString>, quotingFunctions?: ShellQuotingFunctions): string {
122
- return args.map(arg => escapeForShell(arg, quotingFunctions)).join(' ');
123
- }
124
-
125
- /**
126
- * Escape (or quote) a given input.
127
- *
128
- * @param arg Input to escape.
129
- * @param quotingFunctions Collection of functions to process the given `arg`.
130
- * @param quotingType Override the quoting type specified by the given `arg`.
131
- */
132
- export function escapeForShell(arg: string | ShellQuotedString, quotingFunctions?: ShellQuotingFunctions, quotingType?: ShellQuoting): string {
133
- let value: string;
134
- let quoting: ShellQuoting | undefined = quotingType;
135
- if (typeof arg === 'string') {
136
- if (!quoting) {
137
- return arg;
138
- }
139
- value = arg;
140
- } else {
141
- if (!quoting) {
142
- quoting = arg.quoting;
143
- }
144
- value = arg.value;
145
- }
146
- if (quotingFunctions && typeof quotingFunctions[quoting] === 'function') {
147
- return quotingFunctions[quoting]!(value);
148
- }
149
- return value;
150
- }
151
-
152
- export const BashQuotingFunctions: Required<ShellQuotingFunctions> = {
153
- characters: {
154
- needQuotes: '()',
155
- escape: '\\',
156
- strong: '\'',
157
- weak: '"',
158
- },
159
- escape(arg): string {
160
- return arg
161
- .replace(/[\s\\|(){}<>$&;"']/g, '\\$&');
162
- },
163
- strong(arg): string {
164
- // ('+) becomes ('"'+"')
165
- return `'${arg
166
- .replace(/'+/g, '\'"$&"\'')}'`;
167
- },
168
- weak(arg): string {
169
- return `"${arg
170
- // Escape escape-characters.
171
- .replace(/\\"/g, '\\\\"')
172
- // Escape user-specified double-quotes.
173
- .replace(/"/g, '\\"')
174
- // Escape trailing (\), we don't want the user to escape our last quote.
175
- .replace(/\\$/g, '\\\\')}"`;
176
- },
177
- };
178
-
179
- export const CmdQuotingFunctions: Required<ShellQuotingFunctions> = {
180
- characters: {
181
- weak: '"',
182
- },
183
- escape(arg): string {
184
- return arg
185
- // Escape forbidden characters (see: cmd /?).
186
- .replace(/[%&<>()@^|]/g, '^$&')
187
- // Some characters must be escaped using `\`.
188
- .replace(/[\\"]/g, '\\$&')
189
- // Double-quote whitespaces, else we cannot escape it.
190
- .replace(/\s+/g, '"$&"');
191
- },
192
- strong(arg): string {
193
- return this.weak(arg)
194
- // Try to prevent variable expansion.
195
- .replace(/%/g, '"%"');
196
- },
197
- weak(arg): string {
198
- return `"${arg
199
- // Escape double quotes.
200
- .replace(/\\"/g, '\\\\"')
201
- .replace(/"/g, '\\"')
202
- // Escape forbidden characters (see: cmd /?)
203
- .replace(/[&<>()@^|]/g, '^$&')
204
- // Escape trailing backslash, we don't want the user to escape our last quote.
205
- .replace(/\\$/g, '\\\\')
206
- // Escape line returns
207
- .replace(/\r?\n/g, '^$&')}"`;
208
- },
209
- };
210
-
211
- export const PowershellQuotingFunctions: Required<ShellQuotingFunctions> = {
212
- characters: {
213
- needQuotes: '()',
214
- escape: '`',
215
- strong: '\'',
216
- weak: '"',
217
- },
218
- escape(arg): string {
219
- return arg.replace(/[`|{}()<>;"' ]/g, '`$&');
220
- },
221
- strong(arg): string {
222
- // In powershell, one must write ('') for a single quote to be displayed
223
- // within a single quoted string.
224
- return `'${arg
225
- .replace(/'/g, '\'\'')}'`;
226
- },
227
- weak(arg): string {
228
- return `"${arg
229
- // Escape escape-characters.
230
- .replace(/`"/g, '``"')
231
- // Escape user-specified backticks.
232
- .replace(/"/g, '`"')
233
- // Escape trailing (`), we don't want the user to escape our last quote.
234
- .replace(/`$/g, '``')}"`;
235
- },
236
- };
1
+ // *****************************************************************************
2
+ // Copyright (C) 2020 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
+ // #region vscode
18
+
19
+ /*---------------------------------------------------------------------------------------------
20
+ * Copyright (c) Microsoft Corporation. All rights reserved.
21
+ * Licensed under the MIT License. See License.txt in the project root for license information.
22
+ *--------------------------------------------------------------------------------------------*/
23
+
24
+ // See: https://github.com/microsoft/vscode/blob/9ebb7c43bc99fd6e1a295040674d1f8e5831b9be/src/vs/vscode.d.ts#L5326-L5370
25
+
26
+ /**
27
+ * Defines how an argument should be quoted if it contains
28
+ * spaces or unsupported characters.
29
+ */
30
+ export const enum ShellQuoting {
31
+
32
+ /**
33
+ * Character escaping should be used. This for example
34
+ * uses \ on bash and ` on PowerShell.
35
+ */
36
+ Escape = 'escape',
37
+
38
+ /**
39
+ * Strong string quoting should be used. This for example
40
+ * uses " for Windows cmd and ' for bash and PowerShell.
41
+ * Strong quoting treats arguments as literal strings.
42
+ * Under PowerShell echo 'The value is $(2 * 3)' will
43
+ * print `The value is $(2 * 3)`
44
+ */
45
+ Strong = 'strong',
46
+
47
+ /**
48
+ * Weak string quoting should be used. This for example
49
+ * uses " for Windows cmd, bash and PowerShell. Weak quoting
50
+ * still performs some kind of evaluation inside the quoted
51
+ * string. Under PowerShell echo "The value is $(2 * 3)"
52
+ * will print `The value is 6`
53
+ */
54
+ Weak = 'weak'
55
+ }
56
+
57
+ /**
58
+ * A string that will be quoted depending on the used shell.
59
+ */
60
+ export interface ShellQuotedString {
61
+ /**
62
+ * The actual string value.
63
+ */
64
+ value: string;
65
+
66
+ /**
67
+ * The quoting style to use.
68
+ */
69
+ quoting: ShellQuoting;
70
+ }
71
+
72
+ // #endregion vscode
73
+
74
+ /**
75
+ * Functions that provide shell quoting capabilities.
76
+ */
77
+ export interface ShellQuotingFunctions {
78
+
79
+ characters: {
80
+ /** Characters that require quotes, white space is always implied. */
81
+ needQuotes?: string
82
+ /** The character used to escape sequences. */
83
+ escape?: string
84
+ /** The character used to quote sequences, preventing variable expansion. */
85
+ strong?: string
86
+ /** The character used to quote sequences, allowing variable expansion. */
87
+ weak?: string
88
+ }
89
+
90
+ /**
91
+ * Should add escape-characters in front of forbidden characters.
92
+ */
93
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
94
+ escape?(this: any, arg: string): string
95
+
96
+ /**
97
+ * Should quote the argument in such a way that variables CANNOT be expanded.
98
+ */
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
+ strong?(this: any, arg: string): string;
101
+
102
+ /**
103
+ * Should quote the argument in such a way that variables CAN be expanded.
104
+ */
105
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
106
+ weak?(this: any, arg: string): string;
107
+ }
108
+
109
+ /**
110
+ * Converts a list of args into an escaped shell command.
111
+ *
112
+ * There are two main use cases when handling command/arguments for a shell:
113
+ * 1. User already wrote the escaped commandline, then just use that.
114
+ * 2. User wants a specific process to be invoked with some arguments.
115
+ *
116
+ * The `createShellCommandLine` function is useful for the latter.
117
+ *
118
+ * @param args Standard list of spawn/exec arguments, first item is the command.
119
+ * @param quotingFunctions Collection of functions to process arguments.
120
+ */
121
+ export function createShellCommandLine(args: Array<string | ShellQuotedString>, quotingFunctions?: ShellQuotingFunctions): string {
122
+ return args.map(arg => escapeForShell(arg, quotingFunctions)).join(' ');
123
+ }
124
+
125
+ /**
126
+ * Escape (or quote) a given input.
127
+ *
128
+ * @param arg Input to escape.
129
+ * @param quotingFunctions Collection of functions to process the given `arg`.
130
+ * @param quotingType Override the quoting type specified by the given `arg`.
131
+ */
132
+ export function escapeForShell(arg: string | ShellQuotedString, quotingFunctions?: ShellQuotingFunctions, quotingType?: ShellQuoting): string {
133
+ let value: string;
134
+ let quoting: ShellQuoting | undefined = quotingType;
135
+ if (typeof arg === 'string') {
136
+ if (!quoting) {
137
+ return arg;
138
+ }
139
+ value = arg;
140
+ } else {
141
+ if (!quoting) {
142
+ quoting = arg.quoting;
143
+ }
144
+ value = arg.value;
145
+ }
146
+ if (quotingFunctions && typeof quotingFunctions[quoting] === 'function') {
147
+ return quotingFunctions[quoting]!(value);
148
+ }
149
+ return value;
150
+ }
151
+
152
+ export const BashQuotingFunctions: Required<ShellQuotingFunctions> = {
153
+ characters: {
154
+ needQuotes: '()',
155
+ escape: '\\',
156
+ strong: '\'',
157
+ weak: '"',
158
+ },
159
+ escape(arg): string {
160
+ return arg
161
+ .replace(/[\s\\|(){}<>$&;"']/g, '\\$&');
162
+ },
163
+ strong(arg): string {
164
+ // ('+) becomes ('"'+"')
165
+ return `'${arg
166
+ .replace(/'+/g, '\'"$&"\'')}'`;
167
+ },
168
+ weak(arg): string {
169
+ return `"${arg
170
+ // Escape escape-characters.
171
+ .replace(/\\"/g, '\\\\"')
172
+ // Escape user-specified double-quotes.
173
+ .replace(/"/g, '\\"')
174
+ // Escape trailing (\), we don't want the user to escape our last quote.
175
+ .replace(/\\$/g, '\\\\')}"`;
176
+ },
177
+ };
178
+
179
+ export const CmdQuotingFunctions: Required<ShellQuotingFunctions> = {
180
+ characters: {
181
+ weak: '"',
182
+ },
183
+ escape(arg): string {
184
+ return arg
185
+ // Escape forbidden characters (see: cmd /?).
186
+ .replace(/[%&<>()@^|]/g, '^$&')
187
+ // Some characters must be escaped using `\`.
188
+ .replace(/[\\"]/g, '\\$&')
189
+ // Double-quote whitespaces, else we cannot escape it.
190
+ .replace(/\s+/g, '"$&"');
191
+ },
192
+ strong(arg): string {
193
+ return this.weak(arg)
194
+ // Try to prevent variable expansion.
195
+ .replace(/%/g, '"%"');
196
+ },
197
+ weak(arg): string {
198
+ return `"${arg
199
+ // Escape double quotes.
200
+ .replace(/\\"/g, '\\\\"')
201
+ .replace(/"/g, '\\"')
202
+ // Escape forbidden characters (see: cmd /?)
203
+ .replace(/[&<>()@^|]/g, '^$&')
204
+ // Escape trailing backslash, we don't want the user to escape our last quote.
205
+ .replace(/\\$/g, '\\\\')
206
+ // Escape line returns
207
+ .replace(/\r?\n/g, '^$&')}"`;
208
+ },
209
+ };
210
+
211
+ export const PowershellQuotingFunctions: Required<ShellQuotingFunctions> = {
212
+ characters: {
213
+ needQuotes: '()',
214
+ escape: '`',
215
+ strong: '\'',
216
+ weak: '"',
217
+ },
218
+ escape(arg): string {
219
+ return arg.replace(/[`|{}()<>;"' ]/g, '`$&');
220
+ },
221
+ strong(arg): string {
222
+ // In powershell, one must write ('') for a single quote to be displayed
223
+ // within a single quoted string.
224
+ return `'${arg
225
+ .replace(/'/g, '\'\'')}'`;
226
+ },
227
+ weak(arg): string {
228
+ return `"${arg
229
+ // Escape escape-characters.
230
+ .replace(/`"/g, '``"')
231
+ // Escape user-specified backticks.
232
+ .replace(/"/g, '`"')
233
+ // Escape trailing (`), we don't want the user to escape our last quote.
234
+ .replace(/`$/g, '``')}"`;
235
+ },
236
+ };
@@ -1 +1 @@
1
- console.log('FORBIDDEN_OK')
1
+ console.log('FORBIDDEN_OK')
@@ -1 +1 @@
1
- console.log('WHITESPACE_OK')
1
+ console.log('WHITESPACE_OK')
@@ -1,47 +1,47 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 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 stream = require('stream');
18
-
19
- /**
20
- * A Node stream like `/dev/null`.
21
- *
22
- * Writing goes to a black hole, reading returns `EOF`.
23
- */
24
- export class DevNullStream extends stream.Duplex {
25
-
26
- constructor(options: {
27
- /**
28
- * Makes this stream call `destroy` on itself, emitting the `close` event.
29
- */
30
- autoDestroy?: boolean,
31
- } = {}) {
32
- super();
33
- if (options.autoDestroy) {
34
- this.destroy();
35
- }
36
- }
37
-
38
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
- override _write(chunk: any, encoding: string, callback: (err?: Error) => void): void {
40
- callback();
41
- }
42
-
43
- override _read(size: number): void {
44
- // eslint-disable-next-line no-null/no-null
45
- this.push(null);
46
- }
47
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 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 stream = require('stream');
18
+
19
+ /**
20
+ * A Node stream like `/dev/null`.
21
+ *
22
+ * Writing goes to a black hole, reading returns `EOF`.
23
+ */
24
+ export class DevNullStream extends stream.Duplex {
25
+
26
+ constructor(options: {
27
+ /**
28
+ * Makes this stream call `destroy` on itself, emitting the `close` event.
29
+ */
30
+ autoDestroy?: boolean,
31
+ } = {}) {
32
+ super();
33
+ if (options.autoDestroy) {
34
+ this.destroy();
35
+ }
36
+ }
37
+
38
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
+ override _write(chunk: any, encoding: string, callback: (err?: Error) => void): void {
40
+ callback();
41
+ }
42
+
43
+ override _read(size: number): void {
44
+ // eslint-disable-next-line no-null/no-null
45
+ this.push(null);
46
+ }
47
+ }
package/src/node/index.ts CHANGED
@@ -1,22 +1,22 @@
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
- export * from './process-manager';
18
- export * from './process';
19
- export * from './raw-process';
20
- export * from './terminal-process';
21
- export * from './task-terminal-process';
22
- export * from './multi-ring-buffer';
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
+ export * from './process-manager';
18
+ export * from './process';
19
+ export * from './raw-process';
20
+ export * from './terminal-process';
21
+ export * from './task-terminal-process';
22
+ export * from './multi-ring-buffer';