Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add in VSCode custom when context for enabling & disabling commands #109

Merged
merged 2 commits into from
Jul 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
6 changes: 6 additions & 0 deletions src/IISExpress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down