Reputation: 4249
I'm developing with Typescript, nodeJS and VS Code.
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
Upvotes: 3
Views: 10715
Reputation: 1317
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)
e.g.: my build:test task in launch.json:
{
"type": "npm",
"script": "build:test",
"identifier": "buildtest",
"group": {
"kind": "test",
"isDefault": true
}
}
and the related debug task:
{
"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"
}
Upvotes: 6