Skip to content

Commit

Permalink
Refactor task execution to separate CLI arguments from CLI path logic
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 16, 2024
1 parent a13e588 commit 4339f56
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/vscode/src/taskprovider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down

0 comments on commit 4339f56

Please sign in to comment.