@theia/process 1.67.0-next.13 → 1.67.0-next.56

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 (86) hide show
  1. package/README.md +1 -1
  2. package/package.json +3 -3
  3. package/lib/common/process-common-module.d.ts +0 -4
  4. package/lib/common/process-common-module.d.ts.map +0 -1
  5. package/lib/common/process-common-module.js +0 -23
  6. package/lib/common/process-common-module.js.map +0 -1
  7. package/lib/common/process-manager-types.d.ts +0 -36
  8. package/lib/common/process-manager-types.d.ts.map +0 -1
  9. package/lib/common/process-manager-types.js +0 -24
  10. package/lib/common/process-manager-types.js.map +0 -1
  11. package/lib/common/shell-command-builder.d.ts +0 -50
  12. package/lib/common/shell-command-builder.d.ts.map +0 -1
  13. package/lib/common/shell-command-builder.js +0 -170
  14. package/lib/common/shell-command-builder.js.map +0 -1
  15. package/lib/common/shell-command-builder.slow-spec.d.ts +0 -10
  16. package/lib/common/shell-command-builder.slow-spec.d.ts.map +0 -1
  17. package/lib/common/shell-command-builder.slow-spec.js +0 -405
  18. package/lib/common/shell-command-builder.slow-spec.js.map +0 -1
  19. package/lib/common/shell-quoting.d.ts +0 -92
  20. package/lib/common/shell-quoting.d.ts.map +0 -1
  21. package/lib/common/shell-quoting.js +0 -146
  22. package/lib/common/shell-quoting.js.map +0 -1
  23. package/lib/common/shell-quoting.spec.d.ts +0 -2
  24. package/lib/common/shell-quoting.spec.d.ts.map +0 -1
  25. package/lib/common/shell-quoting.spec.js +0 -171
  26. package/lib/common/shell-quoting.spec.js.map +0 -1
  27. package/lib/node/dev-null-stream.d.ts +0 -18
  28. package/lib/node/dev-null-stream.d.ts.map +0 -1
  29. package/lib/node/dev-null-stream.js +0 -42
  30. package/lib/node/dev-null-stream.js.map +0 -1
  31. package/lib/node/index.d.ts +0 -7
  32. package/lib/node/index.d.ts.map +0 -1
  33. package/lib/node/index.js +0 -25
  34. package/lib/node/index.js.map +0 -1
  35. package/lib/node/multi-ring-buffer.d.ts +0 -71
  36. package/lib/node/multi-ring-buffer.d.ts.map +0 -1
  37. package/lib/node/multi-ring-buffer.js +0 -300
  38. package/lib/node/multi-ring-buffer.js.map +0 -1
  39. package/lib/node/multi-ring-buffer.spec.d.ts +0 -2
  40. package/lib/node/multi-ring-buffer.spec.d.ts.map +0 -1
  41. package/lib/node/multi-ring-buffer.spec.js +0 -423
  42. package/lib/node/multi-ring-buffer.spec.js.map +0 -1
  43. package/lib/node/process-backend-module.d.ts +0 -4
  44. package/lib/node/process-backend-module.d.ts.map +0 -1
  45. package/lib/node/process-backend-module.js +0 -52
  46. package/lib/node/process-backend-module.js.map +0 -1
  47. package/lib/node/process-manager.d.ts +0 -34
  48. package/lib/node/process-manager.d.ts.map +0 -1
  49. package/lib/node/process-manager.js +0 -103
  50. package/lib/node/process-manager.js.map +0 -1
  51. package/lib/node/process.d.ts +0 -96
  52. package/lib/node/process.d.ts.map +0 -1
  53. package/lib/node/process.js +0 -146
  54. package/lib/node/process.js.map +0 -1
  55. package/lib/node/pseudo-pty.d.ts +0 -24
  56. package/lib/node/pseudo-pty.d.ts.map +0 -1
  57. package/lib/node/pseudo-pty.js +0 -40
  58. package/lib/node/pseudo-pty.js.map +0 -1
  59. package/lib/node/raw-process.d.ts +0 -47
  60. package/lib/node/raw-process.d.ts.map +0 -1
  61. package/lib/node/raw-process.js +0 -104
  62. package/lib/node/raw-process.js.map +0 -1
  63. package/lib/node/raw-process.spec.d.ts +0 -2
  64. package/lib/node/raw-process.spec.d.ts.map +0 -1
  65. package/lib/node/raw-process.spec.js +0 -163
  66. package/lib/node/raw-process.spec.js.map +0 -1
  67. package/lib/node/task-terminal-process.d.ts +0 -11
  68. package/lib/node/task-terminal-process.d.ts.map +0 -1
  69. package/lib/node/task-terminal-process.js +0 -43
  70. package/lib/node/task-terminal-process.js.map +0 -1
  71. package/lib/node/terminal-process.d.ts +0 -61
  72. package/lib/node/terminal-process.d.ts.map +0 -1
  73. package/lib/node/terminal-process.js +0 -252
  74. package/lib/node/terminal-process.js.map +0 -1
  75. package/lib/node/terminal-process.spec.d.ts +0 -2
  76. package/lib/node/terminal-process.spec.d.ts.map +0 -1
  77. package/lib/node/terminal-process.spec.js +0 -104
  78. package/lib/node/terminal-process.spec.js.map +0 -1
  79. package/lib/node/test/process-test-container.d.ts +0 -3
  80. package/lib/node/test/process-test-container.d.ts.map +0 -1
  81. package/lib/node/test/process-test-container.js +0 -29
  82. package/lib/node/test/process-test-container.js.map +0 -1
  83. package/lib/node/utils.d.ts +0 -17
  84. package/lib/node/utils.d.ts.map +0 -1
  85. package/lib/node/utils.js +0 -78
  86. package/lib/node/utils.js.map +0 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@ The `@theia/process` extension allows the management of processes started with o
16
16
 
17
17
  ## Additional Information
18
18
 
19
- - [API documentation for `@theia/process`](https://eclipse-theia.github.io/theia/docs/next/modules/process.html)
19
+ - [API documentation for `@theia/process`](https://eclipse-theia.github.io/theia/docs/next/modules/_theia_process.html)
20
20
  - [Theia - GitHub](https://github.com/eclipse-theia/theia)
21
21
  - [Theia - Website](https://theia-ide.org/)
22
22
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@theia/process",
3
- "version": "1.67.0-next.13+c409d5d18",
3
+ "version": "1.67.0-next.56+d8f18cc386c",
4
4
  "description": "Theia process support.",
5
5
  "dependencies": {
6
- "@theia/core": "1.67.0-next.13+c409d5d18",
6
+ "@theia/core": "1.67.0-next.56+d8f18cc386c",
7
7
  "node-pty": "1.1.0-beta27",
8
8
  "string-argv": "^0.1.1",
9
9
  "tslib": "^2.6.2"
@@ -50,5 +50,5 @@
50
50
  "nyc": {
51
51
  "extends": "../../configs/nyc.json"
52
52
  },
53
- "gitHead": "c409d5d18d8c4f5a722f87b37ea9d6fd5af47ea8"
53
+ "gitHead": "d8f18cc386c45a736cd193d42eab02c8f64c6b10"
54
54
  }
@@ -1,4 +0,0 @@
1
- import { ContainerModule } from '@theia/core/shared/inversify';
2
- declare const _default: ContainerModule;
3
- export default _default;
4
- //# sourceMappingURL=process-common-module.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-common-module.d.ts","sourceRoot":"","sources":["../../src/common/process-common-module.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;;AAG/D,wBAEG"}
@@ -1,23 +0,0 @@
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
- const inversify_1 = require("@theia/core/shared/inversify");
19
- const shell_command_builder_1 = require("./shell-command-builder");
20
- exports.default = new inversify_1.ContainerModule((bind, unbind, isBound, rebind) => {
21
- bind(shell_command_builder_1.ShellCommandBuilder).toSelf().inSingletonScope();
22
- });
23
- //# sourceMappingURL=process-common-module.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-common-module.js","sourceRoot":"","sources":["../../src/common/process-common-module.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;AAEhF,4DAA+D;AAC/D,mEAA8D;AAE9D,kBAAe,IAAI,2BAAe,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;IACjE,IAAI,CAAC,2CAAmB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;AAC1D,CAAC,CAAC,CAAC"}
@@ -1,36 +0,0 @@
1
- import { Event } from '@theia/core';
2
- export interface ManagedProcessManager {
3
- register(process: ManagedProcess): number;
4
- unregister(process: ManagedProcess): void;
5
- get(id: number): ManagedProcess | undefined;
6
- }
7
- export interface ManagedProcess {
8
- readonly id: number;
9
- readonly onStart: Event<IProcessStartEvent>;
10
- readonly onExit: Event<IProcessExitEvent>;
11
- readonly onClose: Event<IProcessExitEvent>;
12
- readonly onError: Event<ProcessErrorEvent>;
13
- readonly killed: boolean;
14
- kill(): void;
15
- }
16
- export interface IProcessExitEvent {
17
- readonly code?: number;
18
- readonly signal?: string;
19
- }
20
- /**
21
- * Data emitted when a process has been successfully started.
22
- */
23
- export interface IProcessStartEvent {
24
- }
25
- /**
26
- * Data emitted when a process has failed to start.
27
- */
28
- export interface ProcessErrorEvent extends Error {
29
- /** An errno-like error string (e.g. ENOENT). */
30
- code: string;
31
- }
32
- export declare enum ProcessType {
33
- 'Raw' = 0,
34
- 'Terminal' = 1
35
- }
36
- //# sourceMappingURL=process-manager-types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-manager-types.d.ts","sourceRoot":"","sources":["../../src/common/process-manager-types.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAAC;IAC1C,UAAU,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC1C,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAAC;CAC/C;AAED,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC;IAC5C,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC1C,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC3C,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC3C,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,IAAI,IAAI,IAAI,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAE9B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,KAAK;IAC5C,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,oBAAY,WAAW;IACnB,KAAK,IAAA;IACL,UAAU,IAAA;CACb"}
@@ -1,24 +0,0 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2022 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.ProcessType = void 0;
19
- var ProcessType;
20
- (function (ProcessType) {
21
- ProcessType[ProcessType["Raw"] = 0] = "Raw";
22
- ProcessType[ProcessType["Terminal"] = 1] = "Terminal";
23
- })(ProcessType || (exports.ProcessType = ProcessType = {}));
24
- //# sourceMappingURL=process-manager-types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"process-manager-types.js","sourceRoot":"","sources":["../../src/common/process-manager-types.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,0CAA0C;AAC1C,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;AAwChF,IAAY,WAGX;AAHD,WAAY,WAAW;IACnB,2CAAK,CAAA;IACL,qDAAU,CAAA;AACd,CAAC,EAHW,WAAW,2BAAX,WAAW,QAGtB"}
@@ -1,50 +0,0 @@
1
- import { ShellQuotedString, ShellQuotingFunctions } from '../common/shell-quoting';
2
- export interface ProcessInfo {
3
- executable: string;
4
- arguments: string[];
5
- }
6
- export interface CommandLineOptions {
7
- cwd: string;
8
- args: string[];
9
- env?: {
10
- [key: string]: string | null;
11
- };
12
- }
13
- /**
14
- * Create command lines ready to be sent to a shell's stdin for evaluation.
15
- */
16
- export declare class ShellCommandBuilder {
17
- /**
18
- * Constructs a command line to run in a shell. The shell could be
19
- * re-used/long-lived, this means we cannot spawn a new process with a nice
20
- * and fresh environment, we need to encode environment modifications into
21
- * the returned command.
22
- *
23
- * Inspired by VS Code implementation, see:
24
- * https://github.com/microsoft/vscode/blob/f395cac4fff0721a8099126172c01411812bcb4a/src/vs/workbench/contrib/debug/node/terminals.ts#L79
25
- *
26
- * @param hostProcessInfo the host terminal process infos
27
- * @param commandOptions program to execute in the host terminal
28
- */
29
- buildCommand(hostProcessInfo: ProcessInfo | undefined, commandOptions: CommandLineOptions): string;
30
- protected buildForBash(args: Array<string | ShellQuotedString>, cwd?: string, env?: Array<[string, string | null]>): string;
31
- protected buildForPowershell(args: Array<string | ShellQuotedString>, cwd?: string, env?: Array<[string, string | null]>): string;
32
- protected buildForCmd(args: Array<string | ShellQuotedString>, cwd?: string, env?: Array<[string, string | null]>): string;
33
- protected buildForDefault(args: Array<string | ShellQuotedString>, cwd?: string, env?: Array<[string, string | null]>): string;
34
- /**
35
- * This method will try to leave `arg[0]` unescaped if possible. The reason
36
- * is that shells like `cmd` expect their own commands like `dir` to be
37
- * unescaped.
38
- *
39
- * @returns empty string if `args` is empty, otherwise an escaped command.
40
- */
41
- protected createShellCommandLine(args: (string | ShellQuotedString)[], quotingFunctions: ShellQuotingFunctions): string;
42
- protected quoteExecutableIfNecessary(exec: string | ShellQuotedString, quotingFunctions: ShellQuotingFunctions): string;
43
- /**
44
- * If this method returns `false` then we definitely need quoting.
45
- *
46
- * May return false positives.
47
- */
48
- protected needsQuoting(arg: string): boolean;
49
- }
50
- //# sourceMappingURL=shell-command-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell-command-builder.d.ts","sourceRoot":"","sources":["../../src/common/shell-command-builder.ts"],"names":[],"mappings":"AAwBA,OAAO,EAC0G,iBAAiB,EAAkB,qBAAqB,EACxK,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,WAAW;IACxB,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,EAAE,CAAA;CACtB;AAED,MAAM,WAAW,kBAAkB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,GAAG,CAAC,EAAE;QACF,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;KAC/B,CAAA;CACJ;AAED;;GAEG;AACH,qBACa,mBAAmB;IAE5B;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,eAAe,EAAE,WAAW,GAAG,SAAS,EAAE,cAAc,EAAE,kBAAkB,GAAG,MAAM;IA2BlG,SAAS,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,MAAM;IAoB3H,SAAS,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,MAAM;IAuBjI,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,MAAM;IAqB1H,SAAS,CAAC,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,MAAM;IAI9H;;;;;;OAMG;IACH,SAAS,CAAC,sBAAsB,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,iBAAiB,CAAC,EAAE,EAAE,gBAAgB,EAAE,qBAAqB,GAAG,MAAM;IAavH,SAAS,CAAC,0BAA0B,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,EAAE,gBAAgB,EAAE,qBAAqB,GAAG,MAAM;IAIvH;;;;OAIG;IACH,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAG/C"}
@@ -1,170 +0,0 @@
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.ShellCommandBuilder = void 0;
19
- const tslib_1 = require("tslib");
20
- /*---------------------------------------------------------------------------------------------
21
- * Copyright (c) Microsoft Corporation. All rights reserved.
22
- * Licensed under the MIT License. See License.txt in the project root for license information.
23
- *--------------------------------------------------------------------------------------------*/
24
- /* eslint-disable no-null/no-null */
25
- const inversify_1 = require("@theia/core/shared/inversify");
26
- const shell_quoting_1 = require("../common/shell-quoting");
27
- /**
28
- * Create command lines ready to be sent to a shell's stdin for evaluation.
29
- */
30
- let ShellCommandBuilder = class ShellCommandBuilder {
31
- /**
32
- * Constructs a command line to run in a shell. The shell could be
33
- * re-used/long-lived, this means we cannot spawn a new process with a nice
34
- * and fresh environment, we need to encode environment modifications into
35
- * the returned command.
36
- *
37
- * Inspired by VS Code implementation, see:
38
- * https://github.com/microsoft/vscode/blob/f395cac4fff0721a8099126172c01411812bcb4a/src/vs/workbench/contrib/debug/node/terminals.ts#L79
39
- *
40
- * @param hostProcessInfo the host terminal process infos
41
- * @param commandOptions program to execute in the host terminal
42
- */
43
- buildCommand(hostProcessInfo, commandOptions) {
44
- const host = hostProcessInfo && hostProcessInfo.executable;
45
- const cwd = commandOptions.cwd;
46
- const args = commandOptions.args.map(value => ({
47
- value, quoting: "strong" /* ShellQuoting.Strong */,
48
- }));
49
- const env = [];
50
- if (commandOptions.env) {
51
- for (const key of Object.keys(commandOptions.env)) {
52
- env.push([key, commandOptions.env[key]]);
53
- }
54
- }
55
- if (host) {
56
- if (/(bash|wsl)(.exe)?$/.test(host)) {
57
- return this.buildForBash(args, cwd, env);
58
- }
59
- else if (/(ps|pwsh|powershell)(.exe)?$/i.test(host)) {
60
- return this.buildForPowershell(args, cwd, env);
61
- }
62
- else if (/cmd(.exe)?$/i.test(host)) {
63
- return this.buildForCmd(args, cwd, env);
64
- }
65
- }
66
- return this.buildForDefault(args, cwd, env);
67
- }
68
- buildForBash(args, cwd, env) {
69
- let command = '';
70
- if (cwd) {
71
- command += `cd ${shell_quoting_1.BashQuotingFunctions.strong(cwd)} && `;
72
- }
73
- if (env === null || env === void 0 ? void 0 : env.length) {
74
- command += 'env';
75
- for (const [key, value] of env) {
76
- if (value === null) {
77
- command += ` -u ${shell_quoting_1.BashQuotingFunctions.strong(key)}`;
78
- }
79
- else {
80
- command += ` ${shell_quoting_1.BashQuotingFunctions.strong(`${key}=${value}`)}`;
81
- }
82
- }
83
- command += ' ';
84
- }
85
- command += this.createShellCommandLine(args, shell_quoting_1.BashQuotingFunctions);
86
- return command;
87
- }
88
- buildForPowershell(args, cwd, env) {
89
- let command = '';
90
- if (cwd) {
91
- command += `cd ${shell_quoting_1.PowershellQuotingFunctions.strong(cwd)}; `;
92
- }
93
- if (env === null || env === void 0 ? void 0 : env.length) {
94
- for (const [key, value] of env) {
95
- // Powershell requires special quoting when dealing with
96
- // environment variable names.
97
- const quotedKey = key
98
- .replace(/`/g, '````')
99
- .replace(/\?/g, '``?');
100
- if (value === null) {
101
- command += `Remove-Item \${env:${quotedKey}}; `;
102
- }
103
- else {
104
- command += `\${env:${quotedKey}}=${shell_quoting_1.PowershellQuotingFunctions.strong(value)}; `;
105
- }
106
- }
107
- }
108
- command += '& ' + this.createShellCommandLine(args, shell_quoting_1.PowershellQuotingFunctions);
109
- return command;
110
- }
111
- buildForCmd(args, cwd, env) {
112
- let command = '';
113
- if (cwd) {
114
- command += `cd ${shell_quoting_1.CmdQuotingFunctions.strong(cwd)} && `;
115
- }
116
- // Current quoting mechanism only works within a nested `cmd` call:
117
- command += 'cmd /C "';
118
- if (env === null || env === void 0 ? void 0 : env.length) {
119
- for (const [key, value] of env) {
120
- if (value === null) {
121
- command += `set ${shell_quoting_1.CmdQuotingFunctions.strong(key)}="" && `;
122
- }
123
- else {
124
- command += `set ${shell_quoting_1.CmdQuotingFunctions.strong(`${key}=${value}`)} && `;
125
- }
126
- }
127
- }
128
- command += this.createShellCommandLine(args, shell_quoting_1.CmdQuotingFunctions);
129
- command += '"';
130
- return command;
131
- }
132
- buildForDefault(args, cwd, env) {
133
- return this.buildForBash(args, cwd, env);
134
- }
135
- /**
136
- * This method will try to leave `arg[0]` unescaped if possible. The reason
137
- * is that shells like `cmd` expect their own commands like `dir` to be
138
- * unescaped.
139
- *
140
- * @returns empty string if `args` is empty, otherwise an escaped command.
141
- */
142
- createShellCommandLine(args, quotingFunctions) {
143
- let command = '';
144
- if (args.length > 0) {
145
- const [exec, ...execArgs] = args;
146
- // Some commands like `dir` should not be quoted for `cmd` to understand:
147
- command += this.quoteExecutableIfNecessary(exec, quotingFunctions);
148
- if (execArgs.length > 0) {
149
- command += ' ' + (0, shell_quoting_1.createShellCommandLine)(execArgs, quotingFunctions);
150
- }
151
- }
152
- return command;
153
- }
154
- quoteExecutableIfNecessary(exec, quotingFunctions) {
155
- return typeof exec === 'string' && !this.needsQuoting(exec) ? exec : (0, shell_quoting_1.escapeForShell)(exec, quotingFunctions);
156
- }
157
- /**
158
- * If this method returns `false` then we definitely need quoting.
159
- *
160
- * May return false positives.
161
- */
162
- needsQuoting(arg) {
163
- return /\W/.test(arg);
164
- }
165
- };
166
- exports.ShellCommandBuilder = ShellCommandBuilder;
167
- exports.ShellCommandBuilder = ShellCommandBuilder = tslib_1.__decorate([
168
- (0, inversify_1.injectable)()
169
- ], ShellCommandBuilder);
170
- //# sourceMappingURL=shell-command-builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell-command-builder.js","sourceRoot":"","sources":["../../src/common/shell-command-builder.ts"],"names":[],"mappings":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,GAAW;QAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACJ,CAAA;AA7IY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,sBAAU,GAAE;GACA,mBAAmB,CA6I/B"}
@@ -1,10 +0,0 @@
1
- /// <reference types="node" />
2
- /**
3
- * This test suite assumes that we run in a NodeJS environment!
4
- */
5
- import { ChildProcess } from 'child_process';
6
- import { ProcessInfo } from './shell-command-builder';
7
- export interface TestProcessInfo extends ProcessInfo {
8
- shell: ChildProcess;
9
- }
10
- //# sourceMappingURL=shell-command-builder.slow-spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shell-command-builder.slow-spec.d.ts","sourceRoot":"","sources":["../../src/common/shell-command-builder.slow-spec.ts"],"names":[],"mappings":";AAgBA;;GAEG;AAEH,OAAO,EAAiC,YAAY,EAAa,MAAM,eAAe,CAAC;AAGvF,OAAO,EAA2C,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAG/F,MAAM,WAAW,eAAgB,SAAQ,WAAW;IAChD,KAAK,EAAE,YAAY,CAAA;CACtB"}