From a11d79fdb5e8d8a372f439d8202241bd1537e84e Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Thu, 16 Jul 2020 17:00:49 +0100 Subject: [PATCH 1/2] Adds our own context when clause key when a site is running or not --- src/IISExpress.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/IISExpress.ts b/src/IISExpress.ts index 7d488ade..f25d7f52 100644 --- a/src/IISExpress.ts +++ b/src/IISExpress.ts @@ -115,6 +115,9 @@ export class IISExpress { this.openWebsite(options); } + // Used to enable/disable commands & to know when a site is running + vscode.commands.executeCommand('setContext', 'iisexpress:siterunning', true); + // Attach all the events & functions to iisProcess this._iisProcess.stdout.on('data', (data: string) =>{ data = this.decode2gbk(data); @@ -162,6 +165,9 @@ export class IISExpress { // Kill the process - which will also hook into the exit event to remove the config entry this._iisProcess.kill('SIGINT'); + // Used to enable/disable commands & to know when a site is running + vscode.commands.executeCommand('setContext', 'iisexpress:siterunning', false); + // Clear the output log this._output!.clear(); this._output!.hide(); From 98415389bda93f2320d186071be0a75a48fb4b72 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Thu, 16 Jul 2020 17:01:41 +0100 Subject: [PATCH 2/2] Update package.json & VSCode contribution points schema to hide/show & disable correct commands when a site is running or not --- package.json | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 80cef9c8..03c92969 100644 --- a/package.json +++ b/package.json @@ -96,31 +96,53 @@ { "command": "extension.iis-express.start", "title": "Start Website", - "category": "IIS Express" + "category": "IIS Express", + "enablement": "iisexpress:siterunning != true && isWindows" }, { "command": "extension.iis-express.stop", "title": "Stop Website", - "category": "IIS Express" + "category": "IIS Express", + "enablement": "iisexpress:siterunning && isWindows" }, { "command": "extension.iis-express.restart", "title": "Restart Website", - "category": "IIS Express" + "category": "IIS Express", + "enablement": "iisexpress:siterunning && isWindows" } ], + "menus": { + "commandPalette": [ + { + "command": "extension.iis-express.start", + "when": "iisexpress:siterunning != true && isWindows" + }, + { + "command": "extension.iis-express.stop", + "when": "iisexpress:siterunning && isWindows" + }, + { + "command": "extension.iis-express.restart", + "when": "iisexpress:siterunning && isWindows" + } + ] + }, "keybindings": [ { "command": "extension.iis-express.start", + "when": "iisexpress:siterunning != true && isWindows", "key": "ctrl+f5" }, { "command": "extension.iis-express.stop", - "key": "shift+f5" + "key": "shift+f5", + "when": "iisexpress:siterunning && isWindows" }, { "command": "extension.iis-express.restart", - "key": "ctrl+shift+f5" + "key": "ctrl+shift+f5", + "when": "iisexpress:siterunning && isWindows" } ], "jsonValidation": [