如何在使用VS Code进行调试之前执行批处理文件 [英] How to execute batch file before debugging with VS Code
问题描述
我正在使用Typescript,nodeJS和VS Code进行开发。
I'm developing with Typescript, nodeJS and VS Code.
使用VS Code进行调试,我在 launch.json
中进行了配置。
Debugging with VS Code, I have configuration in my launch.json
.
{
"type": "node",
"request": "launch",
"name": "Launch via NPM",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script",
"debug"
],
"port": 9229
},
是否可以运行批处理服务启动之前文件?使用控制台我通常会使用
Is it possible to run a batch file before the service is started? With console I would normally run it with
env.cmd
npm start
推荐答案
您应在调试之前创建要执行的新任务带有指定的标识符并将其作为 preLaunchTask插入到launch.json中(任务类型也可以是将作为shell命令执行的 shell类型)
You should create a new task that you want to execute before debug with a specified "identifier" and it as a "preLaunchTask" into your launch.json (the task type can be also a "shell type" that will be executed as a shell command)
例如:我在launch.json中的build:test任务:
e.g.: my build:test task in launch.json:
{
"type": "npm",
"script": "build:test",
"identifier": "buildtest",
"group": {
"kind": "test",
"isDefault": true
}
}
相关的调试任务:
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"preLaunchTask": "buildtest",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"tdd",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/temp/test/index.js"
],
"internalConsoleOptions": "openOnSessionStart"
}
这篇关于如何在使用VS Code进行调试之前执行批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!