visual-studio-code - 任务中的 VS CODE SaveAll
问题描述
我想从任务中执行SaveAll
,例如从任务中调用workbench.action.files.saveAll
。
目标是确保在触发一系列其他任务之前保存所有文件。
- 任务 #1:全部保存 (
workbench.action.files.saveAll
) - 任务 #2:运行 Grunt
dependsOn
任务 #1
tasks.json 看起来像这样
{
"version": "2.0.0",
"tasks": [
{
"command": "workbench.action.files.saveAll",
"label": "SaveAllFiles",
},
{
"type": "grunt",
"task": "default",
"label": "Execute Grunt",
"dependsOn": [
"SaveAllFiles"
],
"problemMatcher": []
}
]
}
理论上,我只需要执行标记为 的任务Execute Grunt
,它就会调用该SaveAllFiles
任务。准确地说,我不想基于 Save 或 SaveAll 事件触发任务;有时我想保存文件,但不想触发其他任务。
解决方案
{
"label": "SaveAllFiles",
"command": "${command:workbench.action.files.saveAll}",
"type": "shell",
"problemMatcher": []
},
{
"type": "grunt",
"task": "default",
"label": "Execute Grunt",
"dependsOn": [
"SaveAllFiles"
],
"dependsOrder": "sequence", // need this, "parallel" is the default otherwise
"problemMatcher": []
}
${command:workbench.action.files.saveAll}
是调用vscode命令的通用形式,也可以通过这种方式调用扩展或宏命令。
这方面的信息在https://code.visualstudio.com/docs/editor/variables-reference#_command-variables中,这使得查找起来有点棘手,因为它不在Tasks
文档中。
推荐阅读
- spring - 我无法发送包含来自另一个类的映射对象的 modelAttribute
- python - 如何在没有 biopython 的情况下将多行 fasta 文件转换为单行 fasta 文件
- office-js - 如何将(反馈)链接集成到我的 Office 加载项到相应的 Microsoft AppSource 条目?
- java - Espresso UI 测试的自动授予权限
- android - 无法使用 youtube 视频 url 在本机反应(适用于 android)中播放视频
- java - 如何解决android中的Firebase API初始化失败?
- unity3d - Unity Multiplayer:当 Y 轴小于 -2 时重置玩家位置
- tree - k树的秩
- java - 是否有用于检查字符串参数模式的 android 注释?
- wpf - 使用 ControlTemplate 时绑定分离问题