add support for command line arguments in grunt task runner (#82819)

fixes #66748
This commit is contained in:
Sohail Rajdev 2019-10-18 14:14:53 +05:30 committed by Alex Ross
parent 00de15d765
commit e10218c359
3 changed files with 11 additions and 5 deletions

View file

@ -55,6 +55,10 @@
"type": "string",
"description": "%grunt.taskDefinition.type.description%"
},
"args": {
"type": "array",
"description": "%grunt.taskDefinition.args.description%"
},
"file": {
"type": "string",
"description": "%grunt.taskDefinition.file.description%"

View file

@ -3,5 +3,6 @@
"displayName": "Grunt support for VS Code",
"config.grunt.autoDetect": "Controls whether auto detection of Grunt tasks is on or off. Default is on.",
"grunt.taskDefinition.type.description": "The Grunt task to customize.",
"grunt.taskDefinition.args.description": "Command line arguments to pass to the grunt task",
"grunt.taskDefinition.file.description": "The Grunt file that provides the task. Can be omitted."
}
}

View file

@ -67,6 +67,7 @@ function showError() {
}
interface GruntTaskDefinition extends vscode.TaskDefinition {
task: string;
args?: string[];
file?: string;
}
@ -121,14 +122,14 @@ class FolderDetector {
}
public async getTask(_task: vscode.Task): Promise<vscode.Task | undefined> {
const gruntTask = (<any>_task.definition).task;
const taskDefinition = <any>_task.definition;
const gruntTask = taskDefinition.task;
if (gruntTask) {
let kind: GruntTaskDefinition = (<any>_task.definition);
let options: vscode.ShellExecutionOptions = { cwd: this.workspaceFolder.uri.fsPath };
let source = 'grunt';
let task = gruntTask.indexOf(' ') === -1
? new vscode.Task(kind, this.workspaceFolder, gruntTask, source, new vscode.ShellExecution(`${await this._gruntCommand} ${gruntTask.name}`, options))
: new vscode.Task(kind, this.workspaceFolder, gruntTask, source, new vscode.ShellExecution(`${await this._gruntCommand} "${gruntTask.name}"`, options));
? new vscode.Task(taskDefinition, this.workspaceFolder, gruntTask, source, new vscode.ShellExecution(`${await this._gruntCommand}`, [gruntTask, ...taskDefinition.args], options))
: new vscode.Task(taskDefinition, this.workspaceFolder, gruntTask, source, new vscode.ShellExecution(`${await this._gruntCommand}`, [`"${gruntTask}"`, ...taskDefinition.args], options));
return task;
}
return undefined;