我在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任务中编写命令列表,但这又有另一个问题:定义是在两个不同的地方(原始任务和连接任务)编写的,这违反了“每个定义必须只在一个地方”的规则。如果团队中有人在一个任务中添加了一个选项,他必须记住在“加入的任务”中添加了than选项。
{   "identifier": "joined task",
    "type": "shell",
    "command": "tsc ; tsc -p ./other-path/tsconfig.json",
    "problemMatcher": [
        "$tsc" // <= I am not shure about this
    ]
}

最佳答案

我想你要找的是:

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

关于typescript - 如何在其他任务中运行两个定义的任务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49718853/

10-11 12:46
查看更多