是否可以从VSCode中的任务运行任务?
示例json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Show In Chrome",
"windows": {
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
},
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": [
"${file}"
],
"type": "process",
},
{
"taskName": "Show Coverage",
// this is the task to call another task
}
]
}
我想要做的是让Show Coverage任务查找coverage文件夹中的文件,然后调用Show In Chrome任务将其显示为正在传递的文件的参数。这可能吗?
答案 0 :(得分:0)
事实证明,docs网站的当前配置未针对任务进行更新。
但是,如果您希望任务调用其他任务,因为它依赖于它们,您只需添加此配置
即可 {
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Show In Chrome",
"identifier": "showInChrome",
"windows": {
"command": "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
},
"osx": {
"command": "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
},
"args": [
"${file}"
],
"type": "process",
},
{
"taskName": "Show Coverage",
"dependsOn": "showInChrome"
}
]
}
这将导致任务运行上一个任务,然后运行它已设置的任何命令。
注意:您可以使用多个依赖项来使用标识符数组。