From 55f484cf708a6e0dbb94097fd5a64fc8049165ba Mon Sep 17 00:00:00 2001 From: Colin Dawson Date: Mon, 16 Feb 2026 18:53:14 +0000 Subject: [PATCH] Stopping debug session now stops the tasks --- .vscode/launch.json | 7 ++++--- .vscode/tasks.json | 39 ++++++++++++++++++++++++++++++--------- stop-tasks.ps1 | 23 +++++++++++++++++++++++ 3 files changed, 57 insertions(+), 12 deletions(-) create mode 100644 stop-tasks.ps1 diff --git a/.vscode/launch.json b/.vscode/launch.json index 13849ce..df152b3 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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" diff --git a/.vscode/tasks.json b/.vscode/tasks.json index a3cb746..8551ab6 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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": [] } ] } diff --git a/stop-tasks.ps1 b/stop-tasks.ps1 new file mode 100644 index 0000000..6025f22 --- /dev/null +++ b/stop-tasks.ps1 @@ -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"