我有VSCode版本1.18.1,这在我的Gruntfile.js
grunt.registerTask('release', 'Release process', function(target) {
...
}
我target
就可以运行grunt release:one
或grunt release:two
。但是,我无法弄清楚如何使VSCode使用one|two
目标运行任务。
这是tasks.json
文件VSCode创建时自动检测到Grunt任务。
{
// 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
}
}
]
}
如果我将release:one
放入task
文件的tasks.json
属性,VSCode会抱怨类似
Error: The grunt task detection didn't contribute a task for the following configuration:
有人做过类似的事吗?你能指导我怎么做吗?
谢谢!
答案 0 :(得分:1)
我自己解决这个问题的方法是创建一个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": [],
}
]
}