Skip to content

Commit 8f49092

Browse files
authored
Added a warning for multi-channel install #870 (#875)
1 parent 7ddde0e commit 8f49092

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
All notable changes to this extension will be documented in this file.
44
This extension is available in two release channels for Visual Studio Code from the Visual Studio Marketplace.
5+
We recommend only installing one channel for the best experience.
6+
Installing both channels may cause unexpected behavior.
57

68
- [Preview][ext-preview] - More frequent releases but more likely to contain bugs.
79
- _Preview_ is where updates are available before they released to _Stable_.
@@ -30,6 +32,9 @@ What's changed since v2.4.0:
3032
- General improvements:
3133
- Added starter pipeline snippet for Azure Pipelines by @BernieWhite.
3234
[#851](https://github.com/microsoft/PSRule-vscode/issues/851)
35+
- Added a warning when multiple channels are installed by @BernieWhite.
36+
[#870](https://github.com/microsoft/PSRule-vscode/issues/870)
37+
- Installing both the _Preview_ and _Stable_ channels is not supported and may cause issues.
3338
- Engineering:
3439
- Updated PSRule schema files.
3540
[#844](https://github.com/microsoft/PSRule-vscode/pull/844)

src/extension.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface ExtensionInfo {
2323
version: string;
2424
channel: string;
2525
path: string;
26+
disable: boolean;
2627
}
2728

2829
export class ExtensionManager implements vscode.Disposable {
@@ -65,7 +66,9 @@ export class ExtensionManager implements vscode.Disposable {
6566
public activate(context: vscode.ExtensionContext) {
6667
this._context = context;
6768
this._info = this.checkExtension(context);
68-
this.activateFeatures();
69+
if (!this._info.disable) {
70+
this.activateFeatures();
71+
}
6972
}
7073

7174
public dispose(): void {
@@ -150,6 +153,8 @@ export class ExtensionManager implements vscode.Disposable {
150153
// Get channel
151154
let extensionId = 'bewhite.psrule-vscode';
152155
let extensionChannel = 'stable';
156+
const isStableInstalled = vscode.extensions.getExtension(extensionId) !== undefined;
157+
153158
if (path.basename(context.globalStorageUri.fsPath) === 'bewhite.psrule-vscode-preview') {
154159
extensionId = 'bewhite.psrule-vscode-preview';
155160
extensionChannel = 'preview';
@@ -176,9 +181,9 @@ export class ExtensionManager implements vscode.Disposable {
176181
.getConfiguration('PSRule.notifications')
177182
.get('showChannelUpgrade', true);
178183

184+
const showExtension = 'Show Extension';
179185
if ((extensionChannel === 'preview' || extensionChannel === 'dev') && showChannelUpgrade) {
180186
const showReleaseNotes = 'Show Release Notes';
181-
const showExtension = 'Show Extension';
182187
const alwaysIgnore = 'Always Ignore';
183188

184189
vscode.window
@@ -209,11 +214,29 @@ export class ExtensionManager implements vscode.Disposable {
209214
});
210215
}
211216

217+
let disable = false;
218+
if ((extensionChannel === 'preview' || extensionChannel === 'dev') && isStableInstalled) {
219+
disable = true;
220+
vscode.window.showWarningMessage(
221+
`You may experience issues running the ${extensionChannel} version of PSRule, side-by-side with the stable version. Please uninstall one of ${extensionChannel} or stable version and reload Visual Studio Code for the best experience.`,
222+
showExtension,
223+
)
224+
.then((choice) => {
225+
if (choice === showExtension) {
226+
vscode.commands.executeCommand(
227+
'workbench.extensions.search',
228+
'PSRule'
229+
);
230+
}
231+
});
232+
}
233+
212234
const result: ExtensionInfo = {
213235
id: extensionId,
214236
version: extensionVersion,
215237
channel: extensionChannel,
216238
path: context.extensionPath,
239+
disable: disable,
217240
};
218241
return result;
219242
}

0 commit comments

Comments
 (0)