gpt4 book ai didi

visual-studio-code - 从 postDebugTask 中终止另一个任务 - VS Code

转载 作者:行者123 更新时间:2023-12-03 23:12:53 33 4
gpt4 key购买 nike

我有一个调试启动配置( launch.json ),如下所示。

{
"version": "0.2.0",
"configurations": [
{
"name": "Current TS File",
"type": "node",
"request": "launch",
"preLaunchTask": "Pre Debug Task",
"postDebugTask": "Stop Watch Styles",
"args": ["${relativeFile}"],
"runtimeArgs": ["--nolazy", "-r", "ts-node/register"],
"sourceMaps": true,
"cwd": "${workspaceRoot}",
"protocol": "inspector",
}
]
}

我的任务配置( tasks.json )就像
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "next:copy",
"label": "Copy Files",
"problemMatcher": []
},
{
"type": "npm",
"script": "styles:tsw",
"label": "Watch Styles",
"problemMatcher": [],
},
{
"label": "Pre Debug Task",
"isBackground": true,
"dependsOn" :[
"Copy Files",
"Watch Styles"
]
},
{
"label": "Stop Watch Styles",
// No sure what should come here
}
]
}

尝试在 postDebugTask 中停止监视进程,有没有办法通过在 tasks.json 中提供名称( Watch Styles )作为参数来终止任务。观察样式是一个持续运行的过程,请建议在调试完成后是否有其他方法终止任务。

最佳答案

这将在调试停止后终止所有任务

或者在这种情况下,只是 build_runner watch ...

启动文件

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Flutter",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"preLaunchTask": "flutter: build_runner watch",
"postDebugTask": "Terminate All Tasks"
}
]
}

任务文件
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Terminate All Tasks",
"command": "echo ${input:terminate}",
"type": "shell",
"problemMatcher": []
}
],
"inputs": [
{
"id": "terminate",
"type": "command",
"command": "workbench.action.tasks.terminate",
"args": "terminateAll"
}
]
}

更多信息在这里: https://code.visualstudio.com/docs/editor/variables-reference#_command-variables

关于visual-studio-code - 从 postDebugTask 中终止另一个任务 - VS Code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54480792/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com