2

我在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
    ]
}
4

1 回答 1

3

我想你正在寻找dependsOn

{
    "label": "joined task",
    "dependsOn": ["tsc-main", "tsc-other"]
}
于 2018-04-08T21:45:45.133 回答