【问题标题】:How to run two defined tasks within other task如何在其他任务中运行两个定义的任务
【发布时间】:2018-09-18 00:29:18
【问题描述】:

我在 tasks.json

中定义了许多任务
{
  "version": "2.0.0",
  "tasks": [
    {   "identifier": "tsc-main", 
        "type": "typescript",
        "tsconfig": "tsconfig.json",
        "problemMatcher": [
            "$tsc"
        ]
    },
    {   "identifier": "tsc-other", 
        "type": "typescript",
        "tsconfig": "./other-path/tsconfig.json",
        "problemMatcher": [
            "$tsc"
        ]
    }
  ]
}

我想要一个同时运行多个任务的任务。如果另一个有错误,则运行所有而不停止一个。

类似:

{   "identifier": "joined task", 
    "type": "task-list",  // <= does not exists
    "tasks": ["tsc-main","tsc-other"] // <== 
}

另一种方式是在shell中运行所有命令,但我不知道如何通过命令行运行任务

{   "identifier": "joined task", 
    "type": "shell",
    "command": "task tsc-main ; task tsc-other", // <== I don't know how to write "task"
    "problemMatcher": [
            "$tsc"
    ]
}

我也知道如何在 shell 任务中编写命令列表,但这还有另一个问题:定义写在两个不同的地方(原始任务和连接任务),这违反了规则“每个定义必须只在一个地方”。如果团队中的某个人为一项任务添加了一个选项,他必须记住将选项添加到“加入的任务”中。

{   "identifier": "joined task", 
    "type": "shell",
    "command": "tsc ; tsc -p ./other-path/tsconfig.json", 
    "problemMatcher": [
        "$tsc" // <= I am not shure about this
    ]
}

【问题讨论】:

    标签: typescript visual-studio-code tsc vscode-tasks


    【解决方案1】:

    我想你在找dependsOn

    {
        "label": "joined task",
        "dependsOn": ["tsc-main", "tsc-other"]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-10
      • 1970-01-01
      • 2015-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-30
      相关资源
      最近更新 更多