Stopping debug session now stops the tasks

This commit is contained in:
Colin Dawson 2026-02-16 18:53:14 +00:00
parent 97909483d4
commit 55f484cf70
3 changed files with 57 additions and 12 deletions

7
.vscode/launch.json vendored
View File

@ -6,7 +6,7 @@
"configurations": [
{
"name": "Debug React App",
"type": "chrome",
"type": "pwa-chrome",
"request": "launch",
"url": "http://localhost:3001",
"webRoot": "${workspaceFolder}/src",
@ -15,11 +15,12 @@
"--remote-debugging-port=9222",
"--user-data-dir=C:\\ChromeDebug"
],
"preLaunchTask": "Start All"
"preLaunchTask": "Start All",
"postDebugTask": "Stop All Tasks"
},
{
"name": "Attach to Chrome",
"type": "chrome",
"type": "pwa-chrome",
"request": "attach",
"port": 9222,
"webRoot": "${workspaceFolder}/src"

39
.vscode/tasks.json vendored
View File

@ -3,13 +3,15 @@
"tasks": [
{
"label": "Start Proxy",
"type": "shell",
"type": "process",
"command": "./proxy.cmd",
"isBackground": true,
"runOptions": {
"reevaluateOnRerun": true,
"terminateOnExit": true
},
"problemMatcher": {
"pattern": {
"regexp": ".*"
},
"pattern": { "regexp": ".*" },
"background": {
"activeOnStart": true,
"beginsPattern": "^.*",
@ -19,18 +21,21 @@
},
{
"label": "Start CRA",
"type": "shell",
"command": "npm start",
"type": "process",
"command": "npm",
"args": ["start"],
"isBackground": true,
"runOptions": {
"reevaluateOnRerun": true,
"terminateOnExit": true
},
"options": {
"env": {
"BROWSER": "none"
}
},
"problemMatcher": {
"pattern": {
"regexp": ".*"
},
"pattern": { "regexp": ".*" },
"background": {
"activeOnStart": true,
"beginsPattern": "^.*",
@ -42,6 +47,22 @@
"label": "Start All",
"dependsOn": ["Start Proxy", "Start CRA"],
"dependsOrder": "parallel"
},
{
"label": "Stop All Tasks",
"type": "shell",
"command": "powershell",
"args": [
"-ExecutionPolicy",
"Bypass",
"-File",
"${workspaceFolder}/stop-tasks.ps1"
],
"presentation": {
"reveal": "always",
"panel": "dedicated"
},
"problemMatcher": []
}
]
}

23
stop-tasks.ps1 Normal file
View File

@ -0,0 +1,23 @@
# Stop all tasks started by VS Code debugging
Write-Host "Stopping development tasks..."
# Find and stop processes by command line
$processes = Get-WmiObject Win32_Process | Where-Object {
($_.CommandLine -like '*proxy.cmd*') -or
($_.CommandLine -like '*npm*start*') -or
($_.CommandLine -like '*react-scripts*')
}
foreach ($proc in $processes) {
Write-Host "Stopping process $($proc.ProcessId): $($proc.Name)"
Stop-Process -Id $proc.ProcessId -Force -ErrorAction SilentlyContinue
# Also stop child processes
$children = Get-WmiObject Win32_Process | Where-Object { $_.ParentProcessId -eq $proc.ProcessId }
foreach ($child in $children) {
Write-Host "Stopping child process $($child.ProcessId): $($child.Name)"
Stop-Process -Id $child.ProcessId -Force -ErrorAction SilentlyContinue
}
}
Write-Host "Tasks stopped"