From 9e11b5c7b36b1e883ba72cd09dedc3ba75103d32 Mon Sep 17 00:00:00 2001 From: Manuel Hentschel <53863351+ManuelHentschel@users.noreply.github.com> Date: Thu, 28 Oct 2021 15:05:23 +0200 Subject: [PATCH 1/2] Fix package installation --- src/helpViewer/packages.ts | 6 +++--- src/util.ts | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/helpViewer/packages.ts b/src/helpViewer/packages.ts index a1d813f6f..2443c58be 100644 --- a/src/helpViewer/packages.ts +++ b/src/helpViewer/packages.ts @@ -215,7 +215,7 @@ export class PackageManager { const prompt = `Are you sure you want to remove package ${pkgName}?`; if(await getConfirmation(prompt, confirmation, cmd)){ - await executeAsTask('Remove Package', rPath, args); + await executeAsTask('Remove Package', rPath, args, true); return true; } else{ return false; @@ -234,7 +234,7 @@ export class PackageManager { const prompt = `Are you sure you want to install package${pluralS}: ${pkgNames.join(', ')}?`; if(skipConfirmation || await getConfirmation(prompt, confirmation, cmd)){ - await executeAsTask('Install Package', rPath, args); + await executeAsTask('Install Package', rPath, args, true); return true; } return false; @@ -249,7 +249,7 @@ export class PackageManager { const prompt = 'Are you sure you want to update all installed packages? This might take some time!'; if(skipConfirmation || await getConfirmation(prompt, confirmation, cmd)){ - await executeAsTask('Update Packages', rPath, args); + await executeAsTask('Update Packages', rPath, args, true); return true; } else{ return false; diff --git a/src/util.ts b/src/util.ts index a3984a4f8..5de268093 100644 --- a/src/util.ts +++ b/src/util.ts @@ -200,13 +200,25 @@ export async function getConfirmation(prompt: string, confirmation?: string, det // executes a given command as shell task // is more transparent thatn background processes without littering the integrated terminals // is not intended for actual user interaction -export async function executeAsTask(name: string, command: string, args?: string[]): Promise { - const taskDefinition = { type: 'shell' }; - const quotedArgs = args.map(arg => { return { value: arg, quoting: vscode.ShellQuoting.Weak }; }); - const taskExecution = new vscode.ShellExecution( - command, - quotedArgs - ); +export async function executeAsTask(name: string, process: string, args?: string[], asProcess?: true): Promise; +export async function executeAsTask(name: string, command: string, args?: string[], asProcess?: false): Promise; +export async function executeAsTask(name: string, cmdOrProcess: string, args?: string[], asProcess: boolean = false): Promise { + let taskDefinition: vscode.TaskDefinition; + let taskExecution: vscode.ShellExecution | vscode.ProcessExecution; + if(asProcess){ + taskDefinition = { type: 'process'}; + taskExecution = new vscode.ProcessExecution( + cmdOrProcess, + args + ); + } else{ + taskDefinition = { type: 'shell' }; + const quotedArgs = args.map(arg => { return { value: arg, quoting: vscode.ShellQuoting.Weak }; }); + taskExecution = new vscode.ShellExecution( + cmdOrProcess, + quotedArgs + ); + } const task = new vscode.Task( taskDefinition, vscode.TaskScope.Global, From 2bd285286b6bec0ef9417ed07276f90f77df2a3b Mon Sep 17 00:00:00 2001 From: Kun Ren Date: Fri, 29 Oct 2021 14:09:52 +0800 Subject: [PATCH 2/2] Fix typo --- src/util.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.ts b/src/util.ts index 5de268093..d38d58bd6 100644 --- a/src/util.ts +++ b/src/util.ts @@ -198,7 +198,7 @@ export async function getConfirmation(prompt: string, confirmation?: string, det } // executes a given command as shell task -// is more transparent thatn background processes without littering the integrated terminals +// is more transparent than background processes without littering the integrated terminals // is not intended for actual user interaction export async function executeAsTask(name: string, process: string, args?: string[], asProcess?: true): Promise; export async function executeAsTask(name: string, command: string, args?: string[], asProcess?: false): Promise;