2

I want to run the default Gulp task with VS code by using the inbuilt feature to do so. My tasks.json is as follows:

{ "version": "2.0.0", "tasks": [ { "type": "gulp", "task": "default", "problemMatcher": [] } ] }

When I run the task with the keyboard shortcut(my keybindings are already modified to run the task), I get an options menu with all the list of the Gulp tasks. To actually run the gulp command, I have to select the 'gulp:default' task from the list. How can I run the task without having to see the list and selecting the 'gulp:default' option?

2 Answers 2

4

In .vscode/tasks.json in the workSpaceRoot:

Try the following - the main thing you need is a "label" to use as an argument in your keybinding - the label can be whatever you want:

{ "version": "2.0.0", "tasks": [ { "label": "Your task label", "command": "gulp", "args": ["default"], "type": "shell", "options": { "cwd": "${workspaceRoot}" } "problemMatcher": [] } ] } 

Keybinding:

 { "key": "shift+escape", "command": "workbench.action.tasks.runTask", "args": "Your task label here" }, 
Sign up to request clarification or add additional context in comments.

Comments

0

press ctlr+shift+B to run the task

tasks.json

{ "tasks": [ { "type": "gulp", "taskName": "gulp", "command": "gulp", "args": [ "html", "css" ], "isShellCommand": true, "isBuildCommand": true } ] }

this will run gulp css and gulp html

4 Comments

This is how tasks worked in 'legacy' VSCode versions. These properties are not supported now and don't work.
The version number is "2.0.0". Are you saying that is legacy version of vsc?
Look at this. This is how tasks were written earlier (VSCode <1.13.1). The version no. "2.0.0" is for the tasks version, not VSCode's version. This is the latest docs for tasks.
well press ctrl+shift+B on vsc and you can create a tasks.json. You will see the version number is 2.0.0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.