From e10218c359d50396790004bbba4a177396ad91fb Mon Sep 17 00:00:00 2001 From: Sohail Rajdev Date: Fri, 18 Oct 2019 14:14:53 +0530 Subject: [PATCH] add support for command line arguments in grunt task runner (#82819) fixes #66748 --- extensions/grunt/package.json | 4 ++++ extensions/grunt/package.nls.json | 3 ++- extensions/grunt/src/main.ts | 9 +++++---- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/extensions/grunt/package.json b/extensions/grunt/package.json index f65cc6e62b0..e1356ce67df 100644 --- a/extensions/grunt/package.json +++ b/extensions/grunt/package.json @@ -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%" diff --git a/extensions/grunt/package.nls.json b/extensions/grunt/package.nls.json index 7f1b68bbe0b..873de038882 100644 --- a/extensions/grunt/package.nls.json +++ b/extensions/grunt/package.nls.json @@ -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." -} \ No newline at end of file +} diff --git a/extensions/grunt/src/main.ts b/extensions/grunt/src/main.ts index 3756d7522e3..d8ef8a82673 100644 --- a/extensions/grunt/src/main.ts +++ b/extensions/grunt/src/main.ts @@ -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 { - const gruntTask = (_task.definition).task; + const taskDefinition = _task.definition; + const gruntTask = taskDefinition.task; if (gruntTask) { - let kind: GruntTaskDefinition = (_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;