@theia/process 1.48.0 → 1.48.1

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,92 +1,92 @@
1
- /**
2
- * Defines how an argument should be quoted if it contains
3
- * spaces or unsupported characters.
4
- */
5
- export declare const enum ShellQuoting {
6
- /**
7
- * Character escaping should be used. This for example
8
- * uses \ on bash and ` on PowerShell.
9
- */
10
- Escape = "escape",
11
- /**
12
- * Strong string quoting should be used. This for example
13
- * uses " for Windows cmd and ' for bash and PowerShell.
14
- * Strong quoting treats arguments as literal strings.
15
- * Under PowerShell echo 'The value is $(2 * 3)' will
16
- * print `The value is $(2 * 3)`
17
- */
18
- Strong = "strong",
19
- /**
20
- * Weak string quoting should be used. This for example
21
- * uses " for Windows cmd, bash and PowerShell. Weak quoting
22
- * still performs some kind of evaluation inside the quoted
23
- * string. Under PowerShell echo "The value is $(2 * 3)"
24
- * will print `The value is 6`
25
- */
26
- Weak = "weak"
27
- }
28
- /**
29
- * A string that will be quoted depending on the used shell.
30
- */
31
- export interface ShellQuotedString {
32
- /**
33
- * The actual string value.
34
- */
35
- value: string;
36
- /**
37
- * The quoting style to use.
38
- */
39
- quoting: ShellQuoting;
40
- }
41
- /**
42
- * Functions that provide shell quoting capabilities.
43
- */
44
- export interface ShellQuotingFunctions {
45
- characters: {
46
- /** Characters that require quotes, white space is always implied. */
47
- needQuotes?: string;
48
- /** The character used to escape sequences. */
49
- escape?: string;
50
- /** The character used to quote sequences, preventing variable expansion. */
51
- strong?: string;
52
- /** The character used to quote sequences, allowing variable expansion. */
53
- weak?: string;
54
- };
55
- /**
56
- * Should add escape-characters in front of forbidden characters.
57
- */
58
- escape?(this: any, arg: string): string;
59
- /**
60
- * Should quote the argument in such a way that variables CANNOT be expanded.
61
- */
62
- strong?(this: any, arg: string): string;
63
- /**
64
- * Should quote the argument in such a way that variables CAN be expanded.
65
- */
66
- weak?(this: any, arg: string): string;
67
- }
68
- /**
69
- * Converts a list of args into an escaped shell command.
70
- *
71
- * There are two main use cases when handling command/arguments for a shell:
72
- * 1. User already wrote the escaped commandline, then just use that.
73
- * 2. User wants a specific process to be invoked with some arguments.
74
- *
75
- * The `createShellCommandLine` function is useful for the latter.
76
- *
77
- * @param args Standard list of spawn/exec arguments, first item is the command.
78
- * @param quotingFunctions Collection of functions to process arguments.
79
- */
80
- export declare function createShellCommandLine(args: Array<string | ShellQuotedString>, quotingFunctions?: ShellQuotingFunctions): string;
81
- /**
82
- * Escape (or quote) a given input.
83
- *
84
- * @param arg Input to escape.
85
- * @param quotingFunctions Collection of functions to process the given `arg`.
86
- * @param quotingType Override the quoting type specified by the given `arg`.
87
- */
88
- export declare function escapeForShell(arg: string | ShellQuotedString, quotingFunctions?: ShellQuotingFunctions, quotingType?: ShellQuoting): string;
89
- export declare const BashQuotingFunctions: Required<ShellQuotingFunctions>;
90
- export declare const CmdQuotingFunctions: Required<ShellQuotingFunctions>;
91
- export declare const PowershellQuotingFunctions: Required<ShellQuotingFunctions>;
1
+ /**
2
+ * Defines how an argument should be quoted if it contains
3
+ * spaces or unsupported characters.
4
+ */
5
+ export declare const enum ShellQuoting {
6
+ /**
7
+ * Character escaping should be used. This for example
8
+ * uses \ on bash and ` on PowerShell.
9
+ */
10
+ Escape = "escape",
11
+ /**
12
+ * Strong string quoting should be used. This for example
13
+ * uses " for Windows cmd and ' for bash and PowerShell.
14
+ * Strong quoting treats arguments as literal strings.
15
+ * Under PowerShell echo 'The value is $(2 * 3)' will
16
+ * print `The value is $(2 * 3)`
17
+ */
18
+ Strong = "strong",
19
+ /**
20
+ * Weak string quoting should be used. This for example
21
+ * uses " for Windows cmd, bash and PowerShell. Weak quoting
22
+ * still performs some kind of evaluation inside the quoted
23
+ * string. Under PowerShell echo "The value is $(2 * 3)"
24
+ * will print `The value is 6`
25
+ */
26
+ Weak = "weak"
27
+ }
28
+ /**
29
+ * A string that will be quoted depending on the used shell.
30
+ */
31
+ export interface ShellQuotedString {
32
+ /**
33
+ * The actual string value.
34
+ */
35
+ value: string;
36
+ /**
37
+ * The quoting style to use.
38
+ */
39
+ quoting: ShellQuoting;
40
+ }
41
+ /**
42
+ * Functions that provide shell quoting capabilities.
43
+ */
44
+ export interface ShellQuotingFunctions {
45
+ characters: {
46
+ /** Characters that require quotes, white space is always implied. */
47
+ needQuotes?: string;
48
+ /** The character used to escape sequences. */
49
+ escape?: string;
50
+ /** The character used to quote sequences, preventing variable expansion. */
51
+ strong?: string;
52
+ /** The character used to quote sequences, allowing variable expansion. */
53
+ weak?: string;
54
+ };
55
+ /**
56
+ * Should add escape-characters in front of forbidden characters.
57
+ */
58
+ escape?(this: any, arg: string): string;
59
+ /**
60
+ * Should quote the argument in such a way that variables CANNOT be expanded.
61
+ */
62
+ strong?(this: any, arg: string): string;
63
+ /**
64
+ * Should quote the argument in such a way that variables CAN be expanded.
65
+ */
66
+ weak?(this: any, arg: string): string;
67
+ }
68
+ /**
69
+ * Converts a list of args into an escaped shell command.
70
+ *
71
+ * There are two main use cases when handling command/arguments for a shell:
72
+ * 1. User already wrote the escaped commandline, then just use that.
73
+ * 2. User wants a specific process to be invoked with some arguments.
74
+ *
75
+ * The `createShellCommandLine` function is useful for the latter.
76
+ *
77
+ * @param args Standard list of spawn/exec arguments, first item is the command.
78
+ * @param quotingFunctions Collection of functions to process arguments.
79
+ */
80
+ export declare function createShellCommandLine(args: Array<string | ShellQuotedString>, quotingFunctions?: ShellQuotingFunctions): string;
81
+ /**
82
+ * Escape (or quote) a given input.
83
+ *
84
+ * @param arg Input to escape.
85
+ * @param quotingFunctions Collection of functions to process the given `arg`.
86
+ * @param quotingType Override the quoting type specified by the given `arg`.
87
+ */
88
+ export declare function escapeForShell(arg: string | ShellQuotedString, quotingFunctions?: ShellQuotingFunctions, quotingType?: ShellQuoting): string;
89
+ export declare const BashQuotingFunctions: Required<ShellQuotingFunctions>;
90
+ export declare const CmdQuotingFunctions: Required<ShellQuotingFunctions>;
91
+ export declare const PowershellQuotingFunctions: Required<ShellQuotingFunctions>;
92
92
  //# sourceMappingURL=shell-quoting.d.ts.map
@@ -1,146 +1,146 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2020 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
- exports.PowershellQuotingFunctions = exports.CmdQuotingFunctions = exports.BashQuotingFunctions = exports.escapeForShell = exports.createShellCommandLine = void 0;
19
- /**
20
- * Converts a list of args into an escaped shell command.
21
- *
22
- * There are two main use cases when handling command/arguments for a shell:
23
- * 1. User already wrote the escaped commandline, then just use that.
24
- * 2. User wants a specific process to be invoked with some arguments.
25
- *
26
- * The `createShellCommandLine` function is useful for the latter.
27
- *
28
- * @param args Standard list of spawn/exec arguments, first item is the command.
29
- * @param quotingFunctions Collection of functions to process arguments.
30
- */
31
- function createShellCommandLine(args, quotingFunctions) {
32
- return args.map(arg => escapeForShell(arg, quotingFunctions)).join(' ');
33
- }
34
- exports.createShellCommandLine = createShellCommandLine;
35
- /**
36
- * Escape (or quote) a given input.
37
- *
38
- * @param arg Input to escape.
39
- * @param quotingFunctions Collection of functions to process the given `arg`.
40
- * @param quotingType Override the quoting type specified by the given `arg`.
41
- */
42
- function escapeForShell(arg, quotingFunctions, quotingType) {
43
- let value;
44
- let quoting = quotingType;
45
- if (typeof arg === 'string') {
46
- if (!quoting) {
47
- return arg;
48
- }
49
- value = arg;
50
- }
51
- else {
52
- if (!quoting) {
53
- quoting = arg.quoting;
54
- }
55
- value = arg.value;
56
- }
57
- if (quotingFunctions && typeof quotingFunctions[quoting] === 'function') {
58
- return quotingFunctions[quoting](value);
59
- }
60
- return value;
61
- }
62
- exports.escapeForShell = escapeForShell;
63
- exports.BashQuotingFunctions = {
64
- characters: {
65
- needQuotes: '()',
66
- escape: '\\',
67
- strong: '\'',
68
- weak: '"',
69
- },
70
- escape(arg) {
71
- return arg
72
- .replace(/[\s\\|(){}<>$&;"']/g, '\\$&');
73
- },
74
- strong(arg) {
75
- // ('+) becomes ('"'+"')
76
- return `'${arg
77
- .replace(/'+/g, '\'"$&"\'')}'`;
78
- },
79
- weak(arg) {
80
- return `"${arg
81
- // Escape escape-characters.
82
- .replace(/\\"/g, '\\\\"')
83
- // Escape user-specified double-quotes.
84
- .replace(/"/g, '\\"')
85
- // Escape trailing (\), we don't want the user to escape our last quote.
86
- .replace(/\\$/g, '\\\\')}"`;
87
- },
88
- };
89
- exports.CmdQuotingFunctions = {
90
- characters: {
91
- weak: '"',
92
- },
93
- escape(arg) {
94
- return arg
95
- // Escape forbidden characters (see: cmd /?).
96
- .replace(/[%&<>()@^|]/g, '^$&')
97
- // Some characters must be escaped using `\`.
98
- .replace(/[\\"]/g, '\\$&')
99
- // Double-quote whitespaces, else we cannot escape it.
100
- .replace(/\s+/g, '"$&"');
101
- },
102
- strong(arg) {
103
- return this.weak(arg)
104
- // Try to prevent variable expansion.
105
- .replace(/%/g, '"%"');
106
- },
107
- weak(arg) {
108
- return `"${arg
109
- // Escape double quotes.
110
- .replace(/\\"/g, '\\\\"')
111
- .replace(/"/g, '\\"')
112
- // Escape forbidden characters (see: cmd /?)
113
- .replace(/[&<>()@^|]/g, '^$&')
114
- // Escape trailing backslash, we don't want the user to escape our last quote.
115
- .replace(/\\$/g, '\\\\')
116
- // Escape line returns
117
- .replace(/\r?\n/g, '^$&')}"`;
118
- },
119
- };
120
- exports.PowershellQuotingFunctions = {
121
- characters: {
122
- needQuotes: '()',
123
- escape: '`',
124
- strong: '\'',
125
- weak: '"',
126
- },
127
- escape(arg) {
128
- return arg.replace(/[`|{}()<>;"' ]/g, '`$&');
129
- },
130
- strong(arg) {
131
- // In powershell, one must write ('') for a single quote to be displayed
132
- // within a single quoted string.
133
- return `'${arg
134
- .replace(/'/g, '\'\'')}'`;
135
- },
136
- weak(arg) {
137
- return `"${arg
138
- // Escape escape-characters.
139
- .replace(/`"/g, '``"')
140
- // Escape user-specified backticks.
141
- .replace(/"/g, '`"')
142
- // Escape trailing (`), we don't want the user to escape our last quote.
143
- .replace(/`$/g, '``')}"`;
144
- },
145
- };
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2020 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
+ exports.PowershellQuotingFunctions = exports.CmdQuotingFunctions = exports.BashQuotingFunctions = exports.escapeForShell = exports.createShellCommandLine = void 0;
19
+ /**
20
+ * Converts a list of args into an escaped shell command.
21
+ *
22
+ * There are two main use cases when handling command/arguments for a shell:
23
+ * 1. User already wrote the escaped commandline, then just use that.
24
+ * 2. User wants a specific process to be invoked with some arguments.
25
+ *
26
+ * The `createShellCommandLine` function is useful for the latter.
27
+ *
28
+ * @param args Standard list of spawn/exec arguments, first item is the command.
29
+ * @param quotingFunctions Collection of functions to process arguments.
30
+ */
31
+ function createShellCommandLine(args, quotingFunctions) {
32
+ return args.map(arg => escapeForShell(arg, quotingFunctions)).join(' ');
33
+ }
34
+ exports.createShellCommandLine = createShellCommandLine;
35
+ /**
36
+ * Escape (or quote) a given input.
37
+ *
38
+ * @param arg Input to escape.
39
+ * @param quotingFunctions Collection of functions to process the given `arg`.
40
+ * @param quotingType Override the quoting type specified by the given `arg`.
41
+ */
42
+ function escapeForShell(arg, quotingFunctions, quotingType) {
43
+ let value;
44
+ let quoting = quotingType;
45
+ if (typeof arg === 'string') {
46
+ if (!quoting) {
47
+ return arg;
48
+ }
49
+ value = arg;
50
+ }
51
+ else {
52
+ if (!quoting) {
53
+ quoting = arg.quoting;
54
+ }
55
+ value = arg.value;
56
+ }
57
+ if (quotingFunctions && typeof quotingFunctions[quoting] === 'function') {
58
+ return quotingFunctions[quoting](value);
59
+ }
60
+ return value;
61
+ }
62
+ exports.escapeForShell = escapeForShell;
63
+ exports.BashQuotingFunctions = {
64
+ characters: {
65
+ needQuotes: '()',
66
+ escape: '\\',
67
+ strong: '\'',
68
+ weak: '"',
69
+ },
70
+ escape(arg) {
71
+ return arg
72
+ .replace(/[\s\\|(){}<>$&;"']/g, '\\$&');
73
+ },
74
+ strong(arg) {
75
+ // ('+) becomes ('"'+"')
76
+ return `'${arg
77
+ .replace(/'+/g, '\'"$&"\'')}'`;
78
+ },
79
+ weak(arg) {
80
+ return `"${arg
81
+ // Escape escape-characters.
82
+ .replace(/\\"/g, '\\\\"')
83
+ // Escape user-specified double-quotes.
84
+ .replace(/"/g, '\\"')
85
+ // Escape trailing (\), we don't want the user to escape our last quote.
86
+ .replace(/\\$/g, '\\\\')}"`;
87
+ },
88
+ };
89
+ exports.CmdQuotingFunctions = {
90
+ characters: {
91
+ weak: '"',
92
+ },
93
+ escape(arg) {
94
+ return arg
95
+ // Escape forbidden characters (see: cmd /?).
96
+ .replace(/[%&<>()@^|]/g, '^$&')
97
+ // Some characters must be escaped using `\`.
98
+ .replace(/[\\"]/g, '\\$&')
99
+ // Double-quote whitespaces, else we cannot escape it.
100
+ .replace(/\s+/g, '"$&"');
101
+ },
102
+ strong(arg) {
103
+ return this.weak(arg)
104
+ // Try to prevent variable expansion.
105
+ .replace(/%/g, '"%"');
106
+ },
107
+ weak(arg) {
108
+ return `"${arg
109
+ // Escape double quotes.
110
+ .replace(/\\"/g, '\\\\"')
111
+ .replace(/"/g, '\\"')
112
+ // Escape forbidden characters (see: cmd /?)
113
+ .replace(/[&<>()@^|]/g, '^$&')
114
+ // Escape trailing backslash, we don't want the user to escape our last quote.
115
+ .replace(/\\$/g, '\\\\')
116
+ // Escape line returns
117
+ .replace(/\r?\n/g, '^$&')}"`;
118
+ },
119
+ };
120
+ exports.PowershellQuotingFunctions = {
121
+ characters: {
122
+ needQuotes: '()',
123
+ escape: '`',
124
+ strong: '\'',
125
+ weak: '"',
126
+ },
127
+ escape(arg) {
128
+ return arg.replace(/[`|{}()<>;"' ]/g, '`$&');
129
+ },
130
+ strong(arg) {
131
+ // In powershell, one must write ('') for a single quote to be displayed
132
+ // within a single quoted string.
133
+ return `'${arg
134
+ .replace(/'/g, '\'\'')}'`;
135
+ },
136
+ weak(arg) {
137
+ return `"${arg
138
+ // Escape escape-characters.
139
+ .replace(/`"/g, '``"')
140
+ // Escape user-specified backticks.
141
+ .replace(/"/g, '`"')
142
+ // Escape trailing (`), we don't want the user to escape our last quote.
143
+ .replace(/`$/g, '``')}"`;
144
+ },
145
+ };
146
146
  //# sourceMappingURL=shell-quoting.js.map
@@ -1,2 +1,2 @@
1
- export {};
1
+ export {};
2
2
  //# sourceMappingURL=shell-quoting.spec.d.ts.map