@theia/task 1.45.0 → 1.46.0-next.72
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 +193 -193
- package/lib/browser/index.d.ts +6 -6
- package/lib/browser/index.js +33 -33
- package/lib/browser/process/process-task-contribution.d.ts +6 -6
- package/lib/browser/process/process-task-contribution.js +43 -43
- package/lib/browser/process/process-task-frontend-module.d.ts +2 -2
- package/lib/browser/process/process-task-frontend-module.js +27 -27
- package/lib/browser/process/process-task-resolver.d.ts +17 -17
- package/lib/browser/process/process-task-resolver.js +101 -101
- package/lib/browser/provided-task-configurations.d.ts +43 -43
- package/lib/browser/provided-task-configurations.js +213 -213
- package/lib/browser/provided-task-configurations.spec.d.ts +1 -1
- package/lib/browser/provided-task-configurations.spec.js +43 -43
- package/lib/browser/quick-open-task.d.ts +144 -144
- package/lib/browser/quick-open-task.d.ts.map +1 -1
- package/lib/browser/quick-open-task.js +752 -748
- package/lib/browser/quick-open-task.js.map +1 -1
- package/lib/browser/task-configuration-manager.d.ts +64 -64
- package/lib/browser/task-configuration-manager.js +261 -261
- package/lib/browser/task-configuration-model.d.ts +32 -32
- package/lib/browser/task-configuration-model.js +79 -79
- package/lib/browser/task-configurations.d.ts +127 -127
- package/lib/browser/task-configurations.js +486 -486
- package/lib/browser/task-contribution.d.ts +182 -182
- package/lib/browser/task-contribution.js +206 -206
- package/lib/browser/task-definition-registry.d.ts +38 -38
- package/lib/browser/task-definition-registry.js +134 -134
- package/lib/browser/task-definition-registry.spec.d.ts +1 -1
- package/lib/browser/task-definition-registry.spec.js +170 -170
- package/lib/browser/task-frontend-contribution.d.ts +56 -56
- package/lib/browser/task-frontend-contribution.js +358 -358
- package/lib/browser/task-frontend-module.d.ts +5 -5
- package/lib/browser/task-frontend-module.js +79 -79
- package/lib/browser/task-name-resolver.d.ts +13 -13
- package/lib/browser/task-name-resolver.js +67 -67
- package/lib/browser/task-node.d.ts +9 -9
- package/lib/browser/task-node.js +17 -17
- package/lib/browser/task-preferences.d.ts +4 -4
- package/lib/browser/task-preferences.js +40 -40
- package/lib/browser/task-problem-matcher-registry.d.ts +40 -40
- package/lib/browser/task-problem-matcher-registry.js +309 -309
- package/lib/browser/task-problem-pattern-registry.d.ts +23 -23
- package/lib/browser/task-problem-pattern-registry.js +210 -210
- package/lib/browser/task-schema-updater.d.ts +58 -58
- package/lib/browser/task-schema-updater.js +688 -688
- package/lib/browser/task-service.d.ts +279 -279
- package/lib/browser/task-service.js +1119 -1119
- package/lib/browser/task-source-resolver.d.ts +9 -9
- package/lib/browser/task-source-resolver.js +51 -51
- package/lib/browser/task-templates.d.ts +13 -13
- package/lib/browser/task-templates.js +161 -161
- package/lib/browser/task-terminal-widget-manager.d.ts +44 -44
- package/lib/browser/task-terminal-widget-manager.js +228 -228
- package/lib/browser/tasks-monaco-contribution.d.ts +1 -1
- package/lib/browser/tasks-monaco-contribution.js +27 -27
- package/lib/common/index.d.ts +4 -4
- package/lib/common/index.js +31 -31
- package/lib/common/problem-matcher-protocol.d.ts +124 -124
- package/lib/common/problem-matcher-protocol.js +132 -132
- package/lib/common/process/task-protocol.d.ts +68 -68
- package/lib/common/process/task-protocol.js +33 -33
- package/lib/common/task-common-module.d.ts +7 -7
- package/lib/common/task-common-module.js +33 -33
- package/lib/common/task-protocol.d.ts +192 -192
- package/lib/common/task-protocol.js +137 -137
- package/lib/common/task-util.d.ts +22 -22
- package/lib/common/task-util.js +46 -46
- package/lib/common/task-watcher.d.ts +17 -17
- package/lib/common/task-watcher.js +86 -86
- package/lib/node/custom/custom-task-runner-backend-module.d.ts +2 -2
- package/lib/node/custom/custom-task-runner-backend-module.js +36 -36
- package/lib/node/custom/custom-task-runner-contribution.d.ts +6 -6
- package/lib/node/custom/custom-task-runner-contribution.js +42 -42
- package/lib/node/custom/custom-task-runner.d.ts +15 -15
- package/lib/node/custom/custom-task-runner.js +69 -69
- package/lib/node/custom/custom-task.d.ts +20 -20
- package/lib/node/custom/custom-task.js +78 -78
- package/lib/node/index.d.ts +3 -3
- package/lib/node/index.js +30 -30
- package/lib/node/process/process-task-runner-backend-module.d.ts +2 -2
- package/lib/node/process/process-task-runner-backend-module.js +36 -36
- package/lib/node/process/process-task-runner-contribution.d.ts +6 -6
- package/lib/node/process/process-task-runner-contribution.js +43 -43
- package/lib/node/process/process-task-runner.d.ts +60 -60
- package/lib/node/process/process-task-runner.js +355 -355
- package/lib/node/process/process-task.d.ts +26 -26
- package/lib/node/process/process-task.js +135 -135
- package/lib/node/process/process-task.spec.d.ts +1 -1
- package/lib/node/process/process-task.spec.js +29 -29
- package/lib/node/task-abstract-line-matcher.d.ts +49 -49
- package/lib/node/task-abstract-line-matcher.js +273 -273
- package/lib/node/task-backend-application-contribution.d.ts +8 -8
- package/lib/node/task-backend-application-contribution.js +48 -48
- package/lib/node/task-backend-module.d.ts +3 -3
- package/lib/node/task-backend-module.js +50 -50
- package/lib/node/task-line-matchers.d.ts +27 -27
- package/lib/node/task-line-matchers.js +121 -121
- package/lib/node/task-manager.d.ts +55 -55
- package/lib/node/task-manager.js +135 -135
- package/lib/node/task-problem-collector.d.ts +10 -10
- package/lib/node/task-problem-collector.js +57 -57
- package/lib/node/task-problem-collector.spec.d.ts +1 -1
- package/lib/node/task-problem-collector.spec.js +310 -310
- package/lib/node/task-runner-protocol.d.ts +16 -16
- package/lib/node/task-runner-protocol.js +19 -19
- package/lib/node/task-runner.d.ts +50 -50
- package/lib/node/task-runner.js +97 -97
- package/lib/node/task-server.d.ts +39 -39
- package/lib/node/task-server.js +237 -237
- package/lib/node/task-server.slow-spec.d.ts +1 -1
- package/lib/node/task-server.slow-spec.js +395 -395
- package/lib/node/task.d.ts +50 -50
- package/lib/node/task.js +77 -77
- package/lib/node/test/task-test-container.d.ts +2 -2
- package/lib/node/test/task-test-container.js +58 -58
- package/package.json +14 -14
- package/src/browser/index.ts +22 -22
- package/src/browser/process/process-task-contribution.ts +31 -31
- package/src/browser/process/process-task-frontend-module.ts +27 -27
- package/src/browser/process/process-task-resolver.ts +89 -89
- package/src/browser/provided-task-configurations.spec.ts +46 -46
- package/src/browser/provided-task-configurations.ts +213 -213
- package/src/browser/quick-open-task.ts +831 -827
- package/src/browser/style/index.css +19 -19
- package/src/browser/task-configuration-manager.ts +256 -256
- package/src/browser/task-configuration-model.ts +101 -101
- package/src/browser/task-configurations.ts +508 -508
- package/src/browser/task-contribution.ts +266 -266
- package/src/browser/task-definition-registry.spec.ts +203 -203
- package/src/browser/task-definition-registry.ts +131 -131
- package/src/browser/task-frontend-contribution.ts +402 -402
- package/src/browser/task-frontend-module.ts +86 -86
- package/src/browser/task-name-resolver.ts +55 -55
- package/src/browser/task-node.ts +37 -37
- package/src/browser/task-preferences.ts +40 -40
- package/src/browser/task-problem-matcher-registry.ts +308 -308
- package/src/browser/task-problem-pattern-registry.ts +196 -196
- package/src/browser/task-schema-updater.ts +701 -701
- package/src/browser/task-service.ts +1164 -1164
- package/src/browser/task-source-resolver.ts +36 -36
- package/src/browser/task-templates.ts +168 -168
- package/src/browser/task-terminal-widget-manager.ts +224 -224
- package/src/browser/tasks-monaco-contribution.ts +27 -27
- package/src/common/index.ts +20 -20
- package/src/common/problem-matcher-protocol.ts +234 -234
- package/src/common/process/task-protocol.ts +97 -97
- package/src/common/task-common-module.ts +34 -34
- package/src/common/task-protocol.ts +317 -317
- package/src/common/task-util.ts +43 -43
- package/src/common/task-watcher.ts +78 -78
- package/src/node/custom/custom-task-runner-backend-module.ts +37 -37
- package/src/node/custom/custom-task-runner-contribution.ts +30 -30
- package/src/node/custom/custom-task-runner.ts +60 -60
- package/src/node/custom/custom-task.ts +73 -73
- package/src/node/index.ts +19 -19
- package/src/node/process/process-task-runner-backend-module.ts +37 -37
- package/src/node/process/process-task-runner-contribution.ts +31 -31
- package/src/node/process/process-task-runner.ts +371 -371
- package/src/node/process/process-task.spec.ts +30 -30
- package/src/node/process/process-task.ts +144 -144
- package/src/node/task-abstract-line-matcher.ts +312 -312
- package/src/node/task-backend-application-contribution.ts +36 -36
- package/src/node/task-backend-module.ts +57 -57
- package/src/node/task-line-matchers.ts +127 -127
- package/src/node/task-manager.ts +129 -129
- package/src/node/task-problem-collector.spec.ts +338 -338
- package/src/node/task-problem-collector.ts +62 -62
- package/src/node/task-runner-protocol.ts +33 -33
- package/src/node/task-runner.ts +96 -96
- package/src/node/task-server.slow-spec.ts +444 -444
- package/src/node/task-server.ts +263 -263
- package/src/node/task.ts +103 -103
- package/src/node/test/task-test-container.ts +63 -63
|
@@ -1,356 +1,356 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// *****************************************************************************
|
|
3
|
-
// Copyright (C) 2017-2019 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
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.ProcessTaskRunner = void 0;
|
|
28
|
-
/*---------------------------------------------------------------------------------------------
|
|
29
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
30
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
31
|
-
*--------------------------------------------------------------------------------------------*/
|
|
32
|
-
const inversify_1 = require("@theia/core/shared/inversify");
|
|
33
|
-
const core_1 = require("@theia/core");
|
|
34
|
-
const node_1 = require("@theia/core/lib/node");
|
|
35
|
-
const node_2 = require("@theia/process/lib/node");
|
|
36
|
-
const shell_quoting_1 = require("@theia/process/lib/common/shell-quoting");
|
|
37
|
-
const process_task_1 = require("./process-task");
|
|
38
|
-
const task_protocol_1 = require("../../common/process/task-protocol");
|
|
39
|
-
const fs = require("fs");
|
|
40
|
-
const shell_process_1 = require("@theia/terminal/lib/node/shell-process");
|
|
41
|
-
/**
|
|
42
|
-
* Task runner that runs a task as a process or a command inside a shell.
|
|
43
|
-
*/
|
|
44
|
-
let ProcessTaskRunner = class ProcessTaskRunner {
|
|
45
|
-
/**
|
|
46
|
-
* Runs a task from the given task configuration.
|
|
47
|
-
* @param taskConfig task configuration to run a task from. The provided task configuration must have a shape of `CommandProperties`.
|
|
48
|
-
*/
|
|
49
|
-
async run(taskConfig, ctx) {
|
|
50
|
-
if (!taskConfig.command) {
|
|
51
|
-
throw new Error("Process task config must have 'command' property specified");
|
|
52
|
-
}
|
|
53
|
-
try {
|
|
54
|
-
// Always spawn a task in a pty, the only difference between shell/process tasks is the
|
|
55
|
-
// way the command is passed:
|
|
56
|
-
// - process: directly look for an executable and pass a specific set of arguments/options.
|
|
57
|
-
// - shell: defer the spawning to a shell that will evaluate a command line with our executable.
|
|
58
|
-
const terminalProcessOptions = this.getResolvedCommand(taskConfig);
|
|
59
|
-
const terminal = this.taskTerminalProcessFactory(terminalProcessOptions);
|
|
60
|
-
// Wait for the confirmation that the process is successfully started, or has failed to start.
|
|
61
|
-
await new Promise((resolve, reject) => {
|
|
62
|
-
terminal.onStart(resolve);
|
|
63
|
-
terminal.onError((error) => {
|
|
64
|
-
reject(task_protocol_1.ProcessTaskError.CouldNotRun(error.code));
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
const processType = (taskConfig.taskType || taskConfig.type);
|
|
68
|
-
return this.taskFactory({
|
|
69
|
-
label: taskConfig.label,
|
|
70
|
-
process: terminal,
|
|
71
|
-
processType,
|
|
72
|
-
context: ctx,
|
|
73
|
-
config: taskConfig,
|
|
74
|
-
command: this.getCommand(processType, terminalProcessOptions)
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
catch (error) {
|
|
78
|
-
this.logger.error(`Error occurred while creating task: ${error}`);
|
|
79
|
-
throw error;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
getResolvedCommand(taskConfig) {
|
|
83
|
-
const osSpecificCommand = this.getOsSpecificCommand(taskConfig);
|
|
84
|
-
const options = osSpecificCommand.options;
|
|
85
|
-
// Use task's cwd with spawned process and pass node env object to
|
|
86
|
-
// new process, so e.g. we can re-use the system path
|
|
87
|
-
if (options) {
|
|
88
|
-
options.env = {
|
|
89
|
-
...process.env,
|
|
90
|
-
...(options.env || {})
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
/** Executable to actually spawn. */
|
|
94
|
-
let command;
|
|
95
|
-
/** List of arguments passed to `command`. */
|
|
96
|
-
let args;
|
|
97
|
-
/**
|
|
98
|
-
* Only useful on Windows, has to do with how node-pty handles complex commands.
|
|
99
|
-
* This string should not include the executable, only what comes after it (arguments).
|
|
100
|
-
*/
|
|
101
|
-
let commandLine;
|
|
102
|
-
if ((taskConfig.taskType || taskConfig.type) === 'shell') {
|
|
103
|
-
// When running a shell task, we have to spawn a shell process somehow,
|
|
104
|
-
// and tell it to run the command the user wants to run inside of it.
|
|
105
|
-
//
|
|
106
|
-
// E.g:
|
|
107
|
-
// - Spawning a process:
|
|
108
|
-
// spawn(process_exe, [...args])
|
|
109
|
-
// - Spawning a shell and run a command:
|
|
110
|
-
// spawn(shell_exe, [shell_exec_cmd_flag, command])
|
|
111
|
-
//
|
|
112
|
-
// The fun part is, the `command` to pass as an argument usually has to be
|
|
113
|
-
// what you would type verbatim inside the shell, so escaping rules apply.
|
|
114
|
-
//
|
|
115
|
-
// What's even more funny is that on Windows, node-pty uses a special
|
|
116
|
-
// mechanism to pass complex escaped arguments, via a string.
|
|
117
|
-
//
|
|
118
|
-
// We need to accommodate most shells, so we need to get specific.
|
|
119
|
-
const { shell } = osSpecificCommand.options;
|
|
120
|
-
command = (shell === null || shell === void 0 ? void 0 : shell.executable) || shell_process_1.ShellProcess.getShellExecutablePath();
|
|
121
|
-
const { execArgs, quotingFunctions } = this.getShellSpecificOptions(command);
|
|
122
|
-
// Allow overriding shell options from task configuration.
|
|
123
|
-
args = (shell === null || shell === void 0 ? void 0 : shell.args) ? [...shell.args] : [...execArgs];
|
|
124
|
-
// Check if an argument list is defined or not. Empty is ok.
|
|
125
|
-
/** Shell command to run: */
|
|
126
|
-
const shellCommand = this.buildShellCommand(osSpecificCommand, quotingFunctions);
|
|
127
|
-
if (core_1.isWindows && /cmd(.exe)?$/.test(command)) {
|
|
128
|
-
// Let's take the following command, including an argument containing whitespace:
|
|
129
|
-
// cmd> node -p process.argv 1 2 " 3"
|
|
130
|
-
//
|
|
131
|
-
// We would expect the following output:
|
|
132
|
-
// json> [ '...\\node.exe', '1', '2', ' 3' ]
|
|
133
|
-
//
|
|
134
|
-
// Let's run this command through `cmd.exe` using `child_process`:
|
|
135
|
-
// js> void childprocess.spawn('cmd.exe', ['/s', '/c', 'node -p process.argv 1 2 " 3"']).stderr.on('data', console.log)
|
|
136
|
-
//
|
|
137
|
-
// We get the correct output, but when using node-pty:
|
|
138
|
-
// js> void nodepty.spawn('cmd.exe', ['/s', '/c', 'node -p process.argv 1 2 " 3"']).on('data', console.log)
|
|
139
|
-
//
|
|
140
|
-
// Then the output looks like:
|
|
141
|
-
// json> [ '...\\node.exe', '1', '2', '"', '3"' ]
|
|
142
|
-
//
|
|
143
|
-
// To fix that, we need to use a special node-pty feature and pass arguments as one string:
|
|
144
|
-
// js> nodepty.spawn('cmd.exe', '/s /c "node -p process.argv 1 2 " 3""')
|
|
145
|
-
//
|
|
146
|
-
// Note the extra quotes that need to be added around the whole command.
|
|
147
|
-
commandLine = [...args, `"${shellCommand}"`].join(' ');
|
|
148
|
-
}
|
|
149
|
-
args.push(shellCommand);
|
|
150
|
-
}
|
|
151
|
-
else {
|
|
152
|
-
// When running process tasks, `command` is the executable to run,
|
|
153
|
-
// and `args` are the arguments we want to pass to it.
|
|
154
|
-
command = osSpecificCommand.command;
|
|
155
|
-
if (Array.isArray(osSpecificCommand.args)) {
|
|
156
|
-
// Process task doesn't handle quotation: Normalize arguments from `ShellQuotedString` to raw `string`.
|
|
157
|
-
args = osSpecificCommand.args.map(arg => typeof arg === 'string' ? arg : arg.value);
|
|
158
|
-
}
|
|
159
|
-
else {
|
|
160
|
-
args = [];
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return { command, args, commandLine, options };
|
|
164
|
-
}
|
|
165
|
-
buildShellCommand(systemSpecificCommand, quotingFunctions) {
|
|
166
|
-
var _a;
|
|
167
|
-
if (Array.isArray(systemSpecificCommand.args)) {
|
|
168
|
-
const commandLineElements = [systemSpecificCommand.command, ...systemSpecificCommand.args].map(arg => {
|
|
169
|
-
// We want to quote arguments only if needed.
|
|
170
|
-
if (quotingFunctions && typeof arg === 'string' && this.argumentNeedsQuotes(arg, quotingFunctions)) {
|
|
171
|
-
return {
|
|
172
|
-
quoting: "strong" /* Strong */,
|
|
173
|
-
value: arg,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
return arg;
|
|
178
|
-
}
|
|
179
|
-
});
|
|
180
|
-
return (0, shell_quoting_1.createShellCommandLine)(commandLineElements, quotingFunctions);
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
// No arguments are provided, so `command` is actually the full command line to execute.
|
|
184
|
-
return (_a = systemSpecificCommand.command) !== null && _a !== void 0 ? _a : '';
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
getShellSpecificOptions(command) {
|
|
188
|
-
if (/bash(.exe)?$/.test(command)) {
|
|
189
|
-
return {
|
|
190
|
-
quotingFunctions: shell_quoting_1.BashQuotingFunctions,
|
|
191
|
-
execArgs: ['-c']
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
else if (/wsl(.exe)?$/.test(command)) {
|
|
195
|
-
return {
|
|
196
|
-
quotingFunctions: shell_quoting_1.BashQuotingFunctions,
|
|
197
|
-
execArgs: ['-e']
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
else if (/cmd(.exe)?$/.test(command)) {
|
|
201
|
-
return {
|
|
202
|
-
quotingFunctions: shell_quoting_1.CmdQuotingFunctions,
|
|
203
|
-
execArgs: ['/S', '/C']
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
else if (/(ps|pwsh|powershell)(.exe)?/.test(command)) {
|
|
207
|
-
return {
|
|
208
|
-
quotingFunctions: shell_quoting_1.PowershellQuotingFunctions,
|
|
209
|
-
execArgs: ['-c']
|
|
210
|
-
};
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
return {
|
|
214
|
-
quotingFunctions: shell_quoting_1.BashQuotingFunctions,
|
|
215
|
-
execArgs: ['-l', '-c']
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
getOsSpecificCommand(taskConfig) {
|
|
220
|
-
// on windows, windows-specific options, if available, take precedence
|
|
221
|
-
if (core_1.isWindows && taskConfig.windows !== undefined) {
|
|
222
|
-
return this.getSystemSpecificCommand(taskConfig, 'windows');
|
|
223
|
-
}
|
|
224
|
-
else if (core_1.isOSX && taskConfig.osx !== undefined) { // on macOS, mac-specific options, if available, take precedence
|
|
225
|
-
return this.getSystemSpecificCommand(taskConfig, 'osx');
|
|
226
|
-
}
|
|
227
|
-
else if (!core_1.isWindows && !core_1.isOSX && taskConfig.linux !== undefined) { // on linux, linux-specific options, if available, take precedence
|
|
228
|
-
return this.getSystemSpecificCommand(taskConfig, 'linux');
|
|
229
|
-
}
|
|
230
|
-
else { // system-specific options are unavailable, use the default
|
|
231
|
-
return this.getSystemSpecificCommand(taskConfig, undefined);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
getCommand(processType, terminalProcessOptions) {
|
|
235
|
-
if (terminalProcessOptions.args) {
|
|
236
|
-
if (processType === 'shell') {
|
|
237
|
-
return terminalProcessOptions.args[terminalProcessOptions.args.length - 1];
|
|
238
|
-
}
|
|
239
|
-
else if (processType === 'process') {
|
|
240
|
-
return `${terminalProcessOptions.command} ${terminalProcessOptions.args.join(' ')}`;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/**
|
|
245
|
-
* This is task specific, to align with VS Code's behavior.
|
|
246
|
-
*
|
|
247
|
-
* When parsing arguments, VS Code will try to detect if the user already
|
|
248
|
-
* tried to quote things.
|
|
249
|
-
*
|
|
250
|
-
* See: https://github.com/microsoft/vscode/blob/d363b988e1e58cf49963841c498681cdc6cb55a3/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts#L1101-L1127
|
|
251
|
-
*
|
|
252
|
-
* @param value
|
|
253
|
-
* @param shellQuotingOptions
|
|
254
|
-
*/
|
|
255
|
-
argumentNeedsQuotes(value, shellQuotingOptions) {
|
|
256
|
-
const { characters } = shellQuotingOptions;
|
|
257
|
-
const needQuotes = new Set([' ', ...characters.needQuotes || []]);
|
|
258
|
-
if (!characters) {
|
|
259
|
-
return false;
|
|
260
|
-
}
|
|
261
|
-
if (value.length >= 2) {
|
|
262
|
-
const first = value[0] === characters.strong ? characters.strong : value[0] === characters.weak ? characters.weak : undefined;
|
|
263
|
-
if (first === value[value.length - 1]) {
|
|
264
|
-
return false;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
let quote;
|
|
268
|
-
for (let i = 0; i < value.length; i++) {
|
|
269
|
-
// We found the end quote.
|
|
270
|
-
const ch = value[i];
|
|
271
|
-
if (ch === quote) {
|
|
272
|
-
quote = undefined;
|
|
273
|
-
}
|
|
274
|
-
else if (quote !== undefined) {
|
|
275
|
-
// skip the character. We are quoted.
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
else if (ch === characters.escape) {
|
|
279
|
-
// Skip the next character
|
|
280
|
-
i++;
|
|
281
|
-
}
|
|
282
|
-
else if (ch === characters.strong || ch === characters.weak) {
|
|
283
|
-
quote = ch;
|
|
284
|
-
}
|
|
285
|
-
else if (needQuotes.has(ch)) {
|
|
286
|
-
return true;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return false;
|
|
290
|
-
}
|
|
291
|
-
getSystemSpecificCommand(taskConfig, system) {
|
|
292
|
-
// initialize with default values from the `taskConfig`
|
|
293
|
-
let command = taskConfig.command;
|
|
294
|
-
let args = taskConfig.args;
|
|
295
|
-
let options = (0, core_1.deepClone)(taskConfig.options) || {};
|
|
296
|
-
if (system) {
|
|
297
|
-
if (taskConfig[system].command) {
|
|
298
|
-
command = taskConfig[system].command;
|
|
299
|
-
}
|
|
300
|
-
if (taskConfig[system].args) {
|
|
301
|
-
args = taskConfig[system].args;
|
|
302
|
-
}
|
|
303
|
-
if (taskConfig[system].options) {
|
|
304
|
-
options = taskConfig[system].options;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (options.cwd) {
|
|
308
|
-
options.cwd = this.asFsPath(options.cwd);
|
|
309
|
-
}
|
|
310
|
-
if (command === undefined) {
|
|
311
|
-
throw new Error('The `command` field of a task cannot be undefined.');
|
|
312
|
-
}
|
|
313
|
-
return { command, args, options };
|
|
314
|
-
}
|
|
315
|
-
asFsPath(uriOrPath) {
|
|
316
|
-
return (uriOrPath.startsWith('file:'))
|
|
317
|
-
? node_1.FileUri.fsPath(uriOrPath)
|
|
318
|
-
: uriOrPath;
|
|
319
|
-
}
|
|
320
|
-
/**
|
|
321
|
-
* @deprecated
|
|
322
|
-
*
|
|
323
|
-
* Remove ProcessTaskRunner.findCommand, introduce process "started" event
|
|
324
|
-
* Checks for the existence of a file, at the provided path, and make sure that
|
|
325
|
-
* it's readable and executable.
|
|
326
|
-
*/
|
|
327
|
-
async executableFileExists(filePath) {
|
|
328
|
-
return new Promise(async (resolve, reject) => {
|
|
329
|
-
fs.access(filePath, fs.constants.F_OK | fs.constants.X_OK, err => {
|
|
330
|
-
resolve(err ? false : true);
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
}
|
|
334
|
-
};
|
|
335
|
-
__decorate([
|
|
336
|
-
(0, inversify_1.inject)(core_1.ILogger),
|
|
337
|
-
(0, inversify_1.named)('task'),
|
|
338
|
-
__metadata("design:type", Object)
|
|
339
|
-
], ProcessTaskRunner.prototype, "logger", void 0);
|
|
340
|
-
__decorate([
|
|
341
|
-
(0, inversify_1.inject)(node_2.RawProcessFactory),
|
|
342
|
-
__metadata("design:type", Function)
|
|
343
|
-
], ProcessTaskRunner.prototype, "rawProcessFactory", void 0);
|
|
344
|
-
__decorate([
|
|
345
|
-
(0, inversify_1.inject)(node_2.TaskTerminalProcessFactory),
|
|
346
|
-
__metadata("design:type", Function)
|
|
347
|
-
], ProcessTaskRunner.prototype, "taskTerminalProcessFactory", void 0);
|
|
348
|
-
__decorate([
|
|
349
|
-
(0, inversify_1.inject)(process_task_1.TaskFactory),
|
|
350
|
-
__metadata("design:type", Function)
|
|
351
|
-
], ProcessTaskRunner.prototype, "taskFactory", void 0);
|
|
352
|
-
ProcessTaskRunner = __decorate([
|
|
353
|
-
(0, inversify_1.injectable)()
|
|
354
|
-
], ProcessTaskRunner);
|
|
355
|
-
exports.ProcessTaskRunner = ProcessTaskRunner;
|
|
1
|
+
"use strict";
|
|
2
|
+
// *****************************************************************************
|
|
3
|
+
// Copyright (C) 2017-2019 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
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
+
};
|
|
23
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.ProcessTaskRunner = void 0;
|
|
28
|
+
/*---------------------------------------------------------------------------------------------
|
|
29
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
30
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
31
|
+
*--------------------------------------------------------------------------------------------*/
|
|
32
|
+
const inversify_1 = require("@theia/core/shared/inversify");
|
|
33
|
+
const core_1 = require("@theia/core");
|
|
34
|
+
const node_1 = require("@theia/core/lib/node");
|
|
35
|
+
const node_2 = require("@theia/process/lib/node");
|
|
36
|
+
const shell_quoting_1 = require("@theia/process/lib/common/shell-quoting");
|
|
37
|
+
const process_task_1 = require("./process-task");
|
|
38
|
+
const task_protocol_1 = require("../../common/process/task-protocol");
|
|
39
|
+
const fs = require("fs");
|
|
40
|
+
const shell_process_1 = require("@theia/terminal/lib/node/shell-process");
|
|
41
|
+
/**
|
|
42
|
+
* Task runner that runs a task as a process or a command inside a shell.
|
|
43
|
+
*/
|
|
44
|
+
let ProcessTaskRunner = class ProcessTaskRunner {
|
|
45
|
+
/**
|
|
46
|
+
* Runs a task from the given task configuration.
|
|
47
|
+
* @param taskConfig task configuration to run a task from. The provided task configuration must have a shape of `CommandProperties`.
|
|
48
|
+
*/
|
|
49
|
+
async run(taskConfig, ctx) {
|
|
50
|
+
if (!taskConfig.command) {
|
|
51
|
+
throw new Error("Process task config must have 'command' property specified");
|
|
52
|
+
}
|
|
53
|
+
try {
|
|
54
|
+
// Always spawn a task in a pty, the only difference between shell/process tasks is the
|
|
55
|
+
// way the command is passed:
|
|
56
|
+
// - process: directly look for an executable and pass a specific set of arguments/options.
|
|
57
|
+
// - shell: defer the spawning to a shell that will evaluate a command line with our executable.
|
|
58
|
+
const terminalProcessOptions = this.getResolvedCommand(taskConfig);
|
|
59
|
+
const terminal = this.taskTerminalProcessFactory(terminalProcessOptions);
|
|
60
|
+
// Wait for the confirmation that the process is successfully started, or has failed to start.
|
|
61
|
+
await new Promise((resolve, reject) => {
|
|
62
|
+
terminal.onStart(resolve);
|
|
63
|
+
terminal.onError((error) => {
|
|
64
|
+
reject(task_protocol_1.ProcessTaskError.CouldNotRun(error.code));
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
const processType = (taskConfig.taskType || taskConfig.type);
|
|
68
|
+
return this.taskFactory({
|
|
69
|
+
label: taskConfig.label,
|
|
70
|
+
process: terminal,
|
|
71
|
+
processType,
|
|
72
|
+
context: ctx,
|
|
73
|
+
config: taskConfig,
|
|
74
|
+
command: this.getCommand(processType, terminalProcessOptions)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
this.logger.error(`Error occurred while creating task: ${error}`);
|
|
79
|
+
throw error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
getResolvedCommand(taskConfig) {
|
|
83
|
+
const osSpecificCommand = this.getOsSpecificCommand(taskConfig);
|
|
84
|
+
const options = osSpecificCommand.options;
|
|
85
|
+
// Use task's cwd with spawned process and pass node env object to
|
|
86
|
+
// new process, so e.g. we can re-use the system path
|
|
87
|
+
if (options) {
|
|
88
|
+
options.env = {
|
|
89
|
+
...process.env,
|
|
90
|
+
...(options.env || {})
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/** Executable to actually spawn. */
|
|
94
|
+
let command;
|
|
95
|
+
/** List of arguments passed to `command`. */
|
|
96
|
+
let args;
|
|
97
|
+
/**
|
|
98
|
+
* Only useful on Windows, has to do with how node-pty handles complex commands.
|
|
99
|
+
* This string should not include the executable, only what comes after it (arguments).
|
|
100
|
+
*/
|
|
101
|
+
let commandLine;
|
|
102
|
+
if ((taskConfig.taskType || taskConfig.type) === 'shell') {
|
|
103
|
+
// When running a shell task, we have to spawn a shell process somehow,
|
|
104
|
+
// and tell it to run the command the user wants to run inside of it.
|
|
105
|
+
//
|
|
106
|
+
// E.g:
|
|
107
|
+
// - Spawning a process:
|
|
108
|
+
// spawn(process_exe, [...args])
|
|
109
|
+
// - Spawning a shell and run a command:
|
|
110
|
+
// spawn(shell_exe, [shell_exec_cmd_flag, command])
|
|
111
|
+
//
|
|
112
|
+
// The fun part is, the `command` to pass as an argument usually has to be
|
|
113
|
+
// what you would type verbatim inside the shell, so escaping rules apply.
|
|
114
|
+
//
|
|
115
|
+
// What's even more funny is that on Windows, node-pty uses a special
|
|
116
|
+
// mechanism to pass complex escaped arguments, via a string.
|
|
117
|
+
//
|
|
118
|
+
// We need to accommodate most shells, so we need to get specific.
|
|
119
|
+
const { shell } = osSpecificCommand.options;
|
|
120
|
+
command = (shell === null || shell === void 0 ? void 0 : shell.executable) || shell_process_1.ShellProcess.getShellExecutablePath();
|
|
121
|
+
const { execArgs, quotingFunctions } = this.getShellSpecificOptions(command);
|
|
122
|
+
// Allow overriding shell options from task configuration.
|
|
123
|
+
args = (shell === null || shell === void 0 ? void 0 : shell.args) ? [...shell.args] : [...execArgs];
|
|
124
|
+
// Check if an argument list is defined or not. Empty is ok.
|
|
125
|
+
/** Shell command to run: */
|
|
126
|
+
const shellCommand = this.buildShellCommand(osSpecificCommand, quotingFunctions);
|
|
127
|
+
if (core_1.isWindows && /cmd(.exe)?$/.test(command)) {
|
|
128
|
+
// Let's take the following command, including an argument containing whitespace:
|
|
129
|
+
// cmd> node -p process.argv 1 2 " 3"
|
|
130
|
+
//
|
|
131
|
+
// We would expect the following output:
|
|
132
|
+
// json> [ '...\\node.exe', '1', '2', ' 3' ]
|
|
133
|
+
//
|
|
134
|
+
// Let's run this command through `cmd.exe` using `child_process`:
|
|
135
|
+
// js> void childprocess.spawn('cmd.exe', ['/s', '/c', 'node -p process.argv 1 2 " 3"']).stderr.on('data', console.log)
|
|
136
|
+
//
|
|
137
|
+
// We get the correct output, but when using node-pty:
|
|
138
|
+
// js> void nodepty.spawn('cmd.exe', ['/s', '/c', 'node -p process.argv 1 2 " 3"']).on('data', console.log)
|
|
139
|
+
//
|
|
140
|
+
// Then the output looks like:
|
|
141
|
+
// json> [ '...\\node.exe', '1', '2', '"', '3"' ]
|
|
142
|
+
//
|
|
143
|
+
// To fix that, we need to use a special node-pty feature and pass arguments as one string:
|
|
144
|
+
// js> nodepty.spawn('cmd.exe', '/s /c "node -p process.argv 1 2 " 3""')
|
|
145
|
+
//
|
|
146
|
+
// Note the extra quotes that need to be added around the whole command.
|
|
147
|
+
commandLine = [...args, `"${shellCommand}"`].join(' ');
|
|
148
|
+
}
|
|
149
|
+
args.push(shellCommand);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
// When running process tasks, `command` is the executable to run,
|
|
153
|
+
// and `args` are the arguments we want to pass to it.
|
|
154
|
+
command = osSpecificCommand.command;
|
|
155
|
+
if (Array.isArray(osSpecificCommand.args)) {
|
|
156
|
+
// Process task doesn't handle quotation: Normalize arguments from `ShellQuotedString` to raw `string`.
|
|
157
|
+
args = osSpecificCommand.args.map(arg => typeof arg === 'string' ? arg : arg.value);
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
args = [];
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return { command, args, commandLine, options };
|
|
164
|
+
}
|
|
165
|
+
buildShellCommand(systemSpecificCommand, quotingFunctions) {
|
|
166
|
+
var _a;
|
|
167
|
+
if (Array.isArray(systemSpecificCommand.args)) {
|
|
168
|
+
const commandLineElements = [systemSpecificCommand.command, ...systemSpecificCommand.args].map(arg => {
|
|
169
|
+
// We want to quote arguments only if needed.
|
|
170
|
+
if (quotingFunctions && typeof arg === 'string' && this.argumentNeedsQuotes(arg, quotingFunctions)) {
|
|
171
|
+
return {
|
|
172
|
+
quoting: "strong" /* Strong */,
|
|
173
|
+
value: arg,
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
else {
|
|
177
|
+
return arg;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return (0, shell_quoting_1.createShellCommandLine)(commandLineElements, quotingFunctions);
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
// No arguments are provided, so `command` is actually the full command line to execute.
|
|
184
|
+
return (_a = systemSpecificCommand.command) !== null && _a !== void 0 ? _a : '';
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
getShellSpecificOptions(command) {
|
|
188
|
+
if (/bash(.exe)?$/.test(command)) {
|
|
189
|
+
return {
|
|
190
|
+
quotingFunctions: shell_quoting_1.BashQuotingFunctions,
|
|
191
|
+
execArgs: ['-c']
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
else if (/wsl(.exe)?$/.test(command)) {
|
|
195
|
+
return {
|
|
196
|
+
quotingFunctions: shell_quoting_1.BashQuotingFunctions,
|
|
197
|
+
execArgs: ['-e']
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
else if (/cmd(.exe)?$/.test(command)) {
|
|
201
|
+
return {
|
|
202
|
+
quotingFunctions: shell_quoting_1.CmdQuotingFunctions,
|
|
203
|
+
execArgs: ['/S', '/C']
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
else if (/(ps|pwsh|powershell)(.exe)?/.test(command)) {
|
|
207
|
+
return {
|
|
208
|
+
quotingFunctions: shell_quoting_1.PowershellQuotingFunctions,
|
|
209
|
+
execArgs: ['-c']
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
return {
|
|
214
|
+
quotingFunctions: shell_quoting_1.BashQuotingFunctions,
|
|
215
|
+
execArgs: ['-l', '-c']
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
getOsSpecificCommand(taskConfig) {
|
|
220
|
+
// on windows, windows-specific options, if available, take precedence
|
|
221
|
+
if (core_1.isWindows && taskConfig.windows !== undefined) {
|
|
222
|
+
return this.getSystemSpecificCommand(taskConfig, 'windows');
|
|
223
|
+
}
|
|
224
|
+
else if (core_1.isOSX && taskConfig.osx !== undefined) { // on macOS, mac-specific options, if available, take precedence
|
|
225
|
+
return this.getSystemSpecificCommand(taskConfig, 'osx');
|
|
226
|
+
}
|
|
227
|
+
else if (!core_1.isWindows && !core_1.isOSX && taskConfig.linux !== undefined) { // on linux, linux-specific options, if available, take precedence
|
|
228
|
+
return this.getSystemSpecificCommand(taskConfig, 'linux');
|
|
229
|
+
}
|
|
230
|
+
else { // system-specific options are unavailable, use the default
|
|
231
|
+
return this.getSystemSpecificCommand(taskConfig, undefined);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
getCommand(processType, terminalProcessOptions) {
|
|
235
|
+
if (terminalProcessOptions.args) {
|
|
236
|
+
if (processType === 'shell') {
|
|
237
|
+
return terminalProcessOptions.args[terminalProcessOptions.args.length - 1];
|
|
238
|
+
}
|
|
239
|
+
else if (processType === 'process') {
|
|
240
|
+
return `${terminalProcessOptions.command} ${terminalProcessOptions.args.join(' ')}`;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* This is task specific, to align with VS Code's behavior.
|
|
246
|
+
*
|
|
247
|
+
* When parsing arguments, VS Code will try to detect if the user already
|
|
248
|
+
* tried to quote things.
|
|
249
|
+
*
|
|
250
|
+
* See: https://github.com/microsoft/vscode/blob/d363b988e1e58cf49963841c498681cdc6cb55a3/src/vs/workbench/contrib/tasks/browser/terminalTaskSystem.ts#L1101-L1127
|
|
251
|
+
*
|
|
252
|
+
* @param value
|
|
253
|
+
* @param shellQuotingOptions
|
|
254
|
+
*/
|
|
255
|
+
argumentNeedsQuotes(value, shellQuotingOptions) {
|
|
256
|
+
const { characters } = shellQuotingOptions;
|
|
257
|
+
const needQuotes = new Set([' ', ...characters.needQuotes || []]);
|
|
258
|
+
if (!characters) {
|
|
259
|
+
return false;
|
|
260
|
+
}
|
|
261
|
+
if (value.length >= 2) {
|
|
262
|
+
const first = value[0] === characters.strong ? characters.strong : value[0] === characters.weak ? characters.weak : undefined;
|
|
263
|
+
if (first === value[value.length - 1]) {
|
|
264
|
+
return false;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
let quote;
|
|
268
|
+
for (let i = 0; i < value.length; i++) {
|
|
269
|
+
// We found the end quote.
|
|
270
|
+
const ch = value[i];
|
|
271
|
+
if (ch === quote) {
|
|
272
|
+
quote = undefined;
|
|
273
|
+
}
|
|
274
|
+
else if (quote !== undefined) {
|
|
275
|
+
// skip the character. We are quoted.
|
|
276
|
+
continue;
|
|
277
|
+
}
|
|
278
|
+
else if (ch === characters.escape) {
|
|
279
|
+
// Skip the next character
|
|
280
|
+
i++;
|
|
281
|
+
}
|
|
282
|
+
else if (ch === characters.strong || ch === characters.weak) {
|
|
283
|
+
quote = ch;
|
|
284
|
+
}
|
|
285
|
+
else if (needQuotes.has(ch)) {
|
|
286
|
+
return true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
getSystemSpecificCommand(taskConfig, system) {
|
|
292
|
+
// initialize with default values from the `taskConfig`
|
|
293
|
+
let command = taskConfig.command;
|
|
294
|
+
let args = taskConfig.args;
|
|
295
|
+
let options = (0, core_1.deepClone)(taskConfig.options) || {};
|
|
296
|
+
if (system) {
|
|
297
|
+
if (taskConfig[system].command) {
|
|
298
|
+
command = taskConfig[system].command;
|
|
299
|
+
}
|
|
300
|
+
if (taskConfig[system].args) {
|
|
301
|
+
args = taskConfig[system].args;
|
|
302
|
+
}
|
|
303
|
+
if (taskConfig[system].options) {
|
|
304
|
+
options = taskConfig[system].options;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
if (options.cwd) {
|
|
308
|
+
options.cwd = this.asFsPath(options.cwd);
|
|
309
|
+
}
|
|
310
|
+
if (command === undefined) {
|
|
311
|
+
throw new Error('The `command` field of a task cannot be undefined.');
|
|
312
|
+
}
|
|
313
|
+
return { command, args, options };
|
|
314
|
+
}
|
|
315
|
+
asFsPath(uriOrPath) {
|
|
316
|
+
return (uriOrPath.startsWith('file:'))
|
|
317
|
+
? node_1.FileUri.fsPath(uriOrPath)
|
|
318
|
+
: uriOrPath;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* @deprecated
|
|
322
|
+
*
|
|
323
|
+
* Remove ProcessTaskRunner.findCommand, introduce process "started" event
|
|
324
|
+
* Checks for the existence of a file, at the provided path, and make sure that
|
|
325
|
+
* it's readable and executable.
|
|
326
|
+
*/
|
|
327
|
+
async executableFileExists(filePath) {
|
|
328
|
+
return new Promise(async (resolve, reject) => {
|
|
329
|
+
fs.access(filePath, fs.constants.F_OK | fs.constants.X_OK, err => {
|
|
330
|
+
resolve(err ? false : true);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
__decorate([
|
|
336
|
+
(0, inversify_1.inject)(core_1.ILogger),
|
|
337
|
+
(0, inversify_1.named)('task'),
|
|
338
|
+
__metadata("design:type", Object)
|
|
339
|
+
], ProcessTaskRunner.prototype, "logger", void 0);
|
|
340
|
+
__decorate([
|
|
341
|
+
(0, inversify_1.inject)(node_2.RawProcessFactory),
|
|
342
|
+
__metadata("design:type", Function)
|
|
343
|
+
], ProcessTaskRunner.prototype, "rawProcessFactory", void 0);
|
|
344
|
+
__decorate([
|
|
345
|
+
(0, inversify_1.inject)(node_2.TaskTerminalProcessFactory),
|
|
346
|
+
__metadata("design:type", Function)
|
|
347
|
+
], ProcessTaskRunner.prototype, "taskTerminalProcessFactory", void 0);
|
|
348
|
+
__decorate([
|
|
349
|
+
(0, inversify_1.inject)(process_task_1.TaskFactory),
|
|
350
|
+
__metadata("design:type", Function)
|
|
351
|
+
], ProcessTaskRunner.prototype, "taskFactory", void 0);
|
|
352
|
+
ProcessTaskRunner = __decorate([
|
|
353
|
+
(0, inversify_1.injectable)()
|
|
354
|
+
], ProcessTaskRunner);
|
|
355
|
+
exports.ProcessTaskRunner = ProcessTaskRunner;
|
|
356
356
|
//# sourceMappingURL=process-task-runner.js.map
|