Skip to content

Commit

Permalink
add support for command line arguments in grunt task runner (microsof…
Browse files Browse the repository at this point in the history
  • Loading branch information
sohailrajdev97 authored and alexr00 committed Oct 18, 2019
1 parent 00de15d commit e10218c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions extensions/grunt/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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%"
Expand Down
3 changes: 2 additions & 1 deletion extensions/grunt/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}
}
9 changes: 5 additions & 4 deletions extensions/grunt/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function showError() {
}
interface GruntTaskDefinition extends vscode.TaskDefinition {
task: string;
args?: string[];
file?: string;
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit e10218c

Please sign in to comment.