在VSCode中使用目标/参数运行grunt任务

8

我使用的是VSCode 1.18.1版本,在我的Gruntfile.js文件中有以下内容:

grunt.registerTask('release', 'Release process', function(target) {
    ...
}

target 的作用是让我能够运行 grunt release:onegrunt release:two。但是,我不知道如何让 VSCode 使用 one|two 目标运行任务。

这是由 VSCode 自动生成的带有 Grunt 任务自动检测的 tasks.json 文件。

{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
    {
        "type": "grunt",
        "task": "release",
        "problemMatcher": [],
        "label": "Release Process",
        "group": {
            "kind": "build",
            "isDefault": true
        }
    }
]
}

如果我在tasks.json文件的task属性中放置release:one,VSCode会报错,类似于:

Error: The grunt task detection didn't contribute a task for the following configuration:

有人做过类似的事情吗?你能告诉我如何做吗?

谢谢!


我在使用gulp时遇到了类似的问题。我已经重新安装了VSCode。 - Arci
1个回答

3
我自己解决这个问题的方法是创建一个类型为shell的任务,然后输入完整的命令。例如,您可以按照以下步骤进行操作:
{ "version": "2.0.0", "tasks": [ { "type": "shell", "label": "Release one", "command": "grunt release:one", "problemMatcher": [], }, { "type": "shell", "label": "Release two", "command": "grunt release:two", "problemMatcher": [], } ] }
请注意,以上代码中保留了HTML标签。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接