Add args to tasks. Use venv in task resolver

This commit is contained in:
Anthony Shaw committed 2021-02-08 16:08:41 +11:00
1 parent 0aa21e5805
commit 2ec6f65e1c
3 files changed
+18 -4

No files matched your search

+8
View File
@@ -34,6 +34,10 @@
"file": {
"type": "string",
"description": "The setup.py file path that provides the command. Can be omitted and root is assumed."
},
"args": {
"type": "array",
"description": "Optional list of arguments to the task"
}
}
},
@@ -50,6 +54,10 @@
"file": {
"type": "string",
"description": "The manage.py file path that provides the command. Can be omitted and root is assumed."
},
"args": {
"type": "array",
"description": "Optional list of arguments to the task"
}
}
}
+5 -2
View File
@@ -29,11 +29,14 @@ export class DjangoTaskProvider implements vscode.TaskProvider {
public resolveTask(_task: vscode.Task): vscode.Task | undefined {
const task = _task.definition.task;
var pythonPath = vscode.workspace.getConfiguration('python').get('pythonPath');
if (!pythonPath){
pythonPath = 'python';
}
if (task) {
// resolveTask requires that the same definition object be used.
const definition: DjangoTaskDefinition = <any>_task.definition;
return new vscode.Task(definition, _task.scope ?? vscode.TaskScope.Workspace, definition.task, 'django', new vscode.ShellExecution(`python ${definition.task}`));
return new vscode.Task(definition, _task.scope ?? vscode.TaskScope.Workspace, definition.task, 'django', new vscode.ShellExecution(`${pythonPath} ${definition.task}`));
}
return undefined;
}
+5 -2
View File
@@ -29,11 +29,14 @@ export class SetupToolsTaskProvider implements vscode.TaskProvider {
public resolveTask(_task: vscode.Task): vscode.Task | undefined {
const task = _task.definition.task;
var pythonPath = vscode.workspace.getConfiguration('python').get('pythonPath');
if (!pythonPath){
pythonPath = 'python';
}
if (task) {
// resolveTask requires that the same definition object be used.
const definition: SetupToolsTaskDefinition = <any>_task.definition;
return new vscode.Task(definition, _task.scope ?? vscode.TaskScope.Workspace, definition.task, 'setuptools', new vscode.ShellExecution(`python ${definition.task}`));
return new vscode.Task(definition, _task.scope ?? vscode.TaskScope.Workspace, definition.task, 'setuptools', new vscode.ShellExecution(`${pythonPath} ${definition.task}`));
}
return undefined;
}