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

Ngo*_*ham 6 gruntjs visual-studio-code

我有VSCode版本1.18.1,这在我的 Gruntfile.js

grunt.registerTask('release', 'Release process', function(target) {
    ...
}
Run Code Online (Sandbox Code Playgroud)

target是我可以运行grunt release:onegrunt release:two.但是,我无法弄清楚如何使VSCode与one|two目标一起运行任务.

这是tasks.json使用自动检测到的Grunt任务创建的文件VSCode.

{
// 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
        }
    }
]
}
Run Code Online (Sandbox Code Playgroud)

如果我把文件release:onetask属性tasks.json,VSCode会抱怨类似的东西

Error: The grunt task detection didn't contribute a task for the following configuration:
Run Code Online (Sandbox Code Playgroud)

有人做过类似的事吗?你能指导我怎么做吗?

谢谢!

Gid*_*zer 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": [], } ] }