From 4339f5641a8af68bd21f3f05b6817fbb88998a44 Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Mon, 16 Sep 2024 21:21:10 +0000 Subject: [PATCH] Refactor task execution to separate CLI arguments from CLI path logic --- packages/vscode/src/taskprovider.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/vscode/src/taskprovider.ts b/packages/vscode/src/taskprovider.ts index a41eafbb23..74a126cebc 100644 --- a/packages/vscode/src/taskprovider.ts +++ b/packages/vscode/src/taskprovider.ts @@ -11,25 +11,23 @@ export async function activeTaskProvider(state: ExtensionState) { const taskProvider: vscode.TaskProvider = { provideTasks: async () => { const { cliPath, cliVersion } = await resolveCli() - const exec = cliPath - ? quoteify(cliPath) - : `npx --yes genaiscript@${cliVersion}` + const exec = cliPath ? quoteify(cliPath) : `npx` + const exeArgs = cliPath + ? [] + : ["--yes", `genaiscript@${cliVersion}`] const scripts = state.project.templates.filter((t) => !t.isSystem) const tasks = scripts.map((script) => { const scriptName = host.path.relative( host.projectFolder(), script.filename ) + const args = [...exeArgs, "run", scriptName, "${relativeFile}"] const task = new vscode.Task( { type: TOOL_ID, script: script.filename }, vscode.TaskScope.Workspace, script.id, TOOL_ID, - new vscode.ShellExecution(exec, [ - "run", - scriptName, - "${relativeFile}", - ]) + new vscode.ShellExecution(exec, args) ) task.detail = `${script.title ?? script.description} - ${scriptName}` task.problemMatchers = [