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?

Mark
  • 143,421
  • 24
  • 428
  • 436
Chirag Bhansali
  • 1,900
  • 1
  • 15
  • 22

2 Answers2

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"
    },
Mark
  • 143,421
  • 24
  • 428
  • 436
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

Sahin Erbay
  • 994
  • 2
  • 12
  • 24
  • This is how tasks worked in 'legacy' VSCode versions. These properties are not supported now and don't work. – Chirag Bhansali Mar 01 '18 at 12:55
  • The version number is "2.0.0". Are you saying that is legacy version of vsc? – Sahin Erbay Mar 01 '18 at 13:19
  • Look at [this](https://code.visualstudio.com/docs/editor/tasks-v1). 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](https://code.visualstudio.com/docs/editor/tasks) is the latest docs for tasks. – Chirag Bhansali Mar 01 '18 at 13:48
  • well press ctrl+shift+B on vsc and you can create a tasks.json. You will see the version number is 2.0.0 – Sahin Erbay Mar 01 '18 at 14:14