MCPcopy Index your code
hub / github.com/REditorSupport/vscode-R / executeAsTask

Function executeAsTask

src/util.ts:254–294  ·  view source on GitHub ↗
(name: string, cmdOrProcess: string, args?: string[], asProcess: boolean = false)

Source from the content-addressed store, hash-verified

252export async function executeAsTask(name: string, process: string, args?: string[], asProcess?: true): Promise<void>;
253export async function executeAsTask(name: string, command: string, args?: string[], asProcess?: false): Promise<void>;
254export 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

Callers 4

removePackageMethod · 0.90
installPackagesMethod · 0.90
updatePackagesMethod · 0.90
promptToInstallRPackageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected