(name: string, cmdOrProcess: string, args?: string[], asProcess: boolean = false)
| 252 | export async function executeAsTask(name: string, process: string, args?: string[], asProcess?: true): Promise<void>; |
| 253 | export async function executeAsTask(name: string, command: string, args?: string[], asProcess?: false): Promise<void>; |
| 254 | export async function executeAsTask(name: string, cmdOrProcess: string, args?: string[], asProcess: boolean = false): Promise<void> { |
| 255 | let taskDefinition: vscode.TaskDefinition; |
| 256 | let taskExecution: vscode.ShellExecution | vscode.ProcessExecution; |
| 257 | if(asProcess){ |
| 258 | taskDefinition = { type: 'process'}; |
| 259 | taskExecution = args ? new vscode.ProcessExecution( |
| 260 | cmdOrProcess, |
| 261 | args |
| 262 | ) : new vscode.ProcessExecution( |
| 263 | cmdOrProcess |
| 264 | ); |
| 265 | } else { |
| 266 | taskDefinition = { type: 'shell' }; |
| 267 | const quotedArgs = args && args.map<vscode.ShellQuotedString>(arg => { return { value: arg, quoting: vscode.ShellQuoting.Weak }; }); |
| 268 | taskExecution = quotedArgs ? new vscode.ShellExecution( |
| 269 | cmdOrProcess, |
| 270 | quotedArgs |
| 271 | ) : new vscode.ShellExecution( |
| 272 | cmdOrProcess |
| 273 | ); |
| 274 | } |
| 275 | const task = new vscode.Task( |
| 276 | taskDefinition, |
| 277 | vscode.TaskScope.Global, |
| 278 | name, |
| 279 | 'R', |
| 280 | taskExecution, |
| 281 | [] |
| 282 | ); |
| 283 | const taskExecutionRunning = await vscode.tasks.executeTask(task); |
| 284 | |
| 285 | const taskDonePromise = new Promise<void>((resolve) => { |
| 286 | vscode.tasks.onDidEndTask(e => { |
| 287 | if (e.execution === taskExecutionRunning) { |
| 288 | resolve(); |
| 289 | } |
| 290 | }); |
| 291 | }); |
| 292 | |
| 293 | return await taskDonePromise; |
| 294 | } |
| 295 | |
| 296 | // executes a callback and shows a 'busy' progress bar during the execution |
| 297 | // synchronous callbacks are converted to async to properly render the progress bar |
no outgoing calls
no test coverage detected