如何使用键盘快捷键运行Gulp任务 [英] How to run a Gulp task with a keyboard shortcut

查看:118
本文介绍了如何使用键盘快捷键运行Gulp任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用内置功能来运行带有VS代码的默认Gulp任务.我的task.json如下:

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": [] } ] }

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

当我使用键盘快捷键运行任务时(我的按键绑定已被修改以运行任务),我将获得一个包含所有Gulp任务列表的选项菜单.要实际运行gulp命令,我必须从列表中选择'gulp:default'任务.如何在不查看列表并选择'gulp:default'选项的情况下运行任务?

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?

推荐答案

在workSpaceRoot的 .vscode/tasks.json 中:

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": []
        }
    ]
}

键盘绑定:

    { "key": "shift+escape",  
      "command": "workbench.action.tasks.runTask", 
      "args": "Your task label here"
    },

这篇关于如何使用键盘快捷键运行Gulp任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆