Kok*_*oko 17 visual-studio-code vscode-tasks
我一直在浏览Visual Studio Code的文档,以弄清楚如何将多个连续任务添加到tasks.json
文件中.
该tasks
数组仅允许为同一命令创建不同的参数.在这个例子中命令是echo
.
{
"version": "0.1.0",
"command": "echo",
"isShellCommand": true,
"args": [],
"showOutput": "always",
"echoCommand": true,
"suppressTaskName": true,
"tasks": [
{
"taskName": "hello",
"args": ["Hello World"]
},
{
"taskName": "bye",
"args": ["Good Bye"]
}
]
}
Run Code Online (Sandbox Code Playgroud)
tasks.json是否允许连续执行多个任务?例如,tsc
接下来是uglify
?
Ben*_*asy 21
该dependsOn
功能在1.10.0版中提供.例如,我使用它来编译和运行TypeScript中的单个文件脚本:
{
"version": "2.0.0",
"tasks": [
{
"command": "tsc -p ${cwd}/2017-play",
"label": "tsc-compile",
"type": "shell"
},
{
"command": "node ${cwd}/2017-play/build/${fileBasenameNoExtension}.js",
"label": "node-exec",
"type": "shell",
"dependsOn": [
"tsc-compile"
],
"problemMatcher": []
}
]
}
Run Code Online (Sandbox Code Playgroud)
下面是一个运行 tcs 构建并使用 shell 脚本将源代码复制到另一个文件夹的工作示例。这是基于 StackOverflow 上的各种帖子以及此处找到的文档:
https://code.visualstudio.com/updates/v1_10#_more-work-on-terminal-runner
还可以创建一个包含两个任务的tasks.json,第二个任务依赖于第一个任务,如 Ben Creeasy 帖子中所示,当第二个任务被调用时,这两个任务将被执行。我需要能够执行其中之一、另一个或两者。非常感谢 Ben,在发表这篇文章之前我很难找到解决方案。
顺便说一句,当包含 shell 文件时,命令是参考项目文件夹运行的,而不是脚本所在的文件夹。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "typescript",
"tsconfig": "tsconfig.json",
"problemMatcher": [
"$tsc"
],
"group": "build",
"identifier": "build"
},
{
"label": "Copy files",
"type": "shell",
"command": "./scripts/copysrc.sh",
"windows": {
"command": ".\\scripts\\copysrc.cmd"
},
"group": "build",
"presentation": {
"reveal": "always"
},
"problemMatcher": [],
"dependsOn": "build"
},
{
"label": "Build and copy",
"dependsOn": [
"build",
"Copy files"
],
"group": "build",
"problemMatcher": []
}
]
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5190 次 |
最近记录: |