From c7bc3f022ef13d39aa5cb5e2d0ef05284cbaf0e3 Mon Sep 17 00:00:00 2001 From: Garry Trinder Date: Mon, 3 Mar 2025 17:50:54 +0000 Subject: [PATCH] Fix stop command. Closes #205 Closes #205 --- CHANGELOG.md | 3 ++- package-lock.json | 4 ++-- package.json | 2 +- src/commands.ts | 27 ++++++++++++++++++++++++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 403e4f5..4aa29c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 > **Note**: odd version numbers, for example, `0.13.0`, are not included in this changelog. They are used to test the new features and fixes before the final release. -## [0.18.2] - 2025-03-03 +## [0.18.3] - 2025-03-03 ### Added: @@ -32,6 +32,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Install: Fixed broken link for Linux - Install: Updated brew tap command to reference new tap location - Install: Fixed incorrect homebrew formulae name +- Commands: Fixed issue with stop command not waiting to ensure Dev Proxy process has fully stopped before disposing of terminal ## [0.16.0] - 2025-02-03 diff --git a/package-lock.json b/package-lock.json index 3bcdf2c..166d0cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dev-proxy-toolkit", - "version": "0.18.2", + "version": "0.18.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dev-proxy-toolkit", - "version": "0.18.2", + "version": "0.18.3", "dependencies": { "json-to-ast": "^2.1.0" }, diff --git a/package.json b/package.json index 8d9cec6..1ccb8e8 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "dev-proxy-toolkit", "displayName": "Dev Proxy Toolkit", "description": "Makes it easy to create and update Dev Proxy configuration files.", - "version": "0.18.2", + "version": "0.18.3", "publisher": "garrytrinder", "engines": { "vscode": "^1.89.0" diff --git a/src/commands.ts b/src/commands.ts index d9b58f9..c8aa254 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -8,7 +8,7 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration vscode.commands.registerCommand('dev-proxy-toolkit.install', async (platform: NodeJS.Platform) => { const versionPreference = configuration.get('version') as VersionPreference; const message = vscode.window.setStatusBarMessage('Installing Dev Proxy...'); - + // we are on windows so we can use winget if (platform === 'win32') { const id = versionPreference === VersionPreference.Stable ? 'Microsoft.DevProxy' : 'Microsoft.DevProxy.Beta'; @@ -35,6 +35,14 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration // we are on macos so we can use brew if (platform === 'darwin') { const id = versionPreference === VersionPreference.Stable ? 'dev-proxy' : 'dev-proxy-beta'; + // check if brew is installed + try { + await executeCommand('brew --version'); + } catch (error) { + await vscode.window.showErrorMessage('Homebrew is not installed. Please install brew and try again.'); + return; + } + try { await executeCommand('brew tap dotnet/dev-proxy'); await executeCommand(`brew install ${id}`); @@ -105,6 +113,23 @@ export const registerCommands = (context: vscode.ExtensionContext, configuration const closeTerminal = configuration.get('closeTerminal') as boolean; if (closeTerminal) { + const checkProxyStatus = async () => { + try { + const response = await fetch(`http://localhost:${apiPort}/proxy`); + return response.ok; + } catch { + return false; + } + }; + + let isRunning = true; + while (isRunning) { + isRunning = await checkProxyStatus(); + if (isRunning) { + await new Promise(resolve => setTimeout(resolve, 1000)); + } + } + vscode.window.terminals.forEach(terminal => { if (terminal.name === 'Dev Proxy') { terminal.dispose();