Skip to content

Commit 9e87460

Browse files
authored
Merge pull request PowerShell#624 from daviwil/update-notification
Add version update notification
2 parents fdffef3 + 95aface commit 9e87460

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/main.ts

+40
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import vscode = require('vscode');
88
import utils = require('./utils');
9+
import path = require('path');
910
import Settings = require('./settings');
1011
import { Logger, LogLevel } from './logging';
1112
import { IFeature } from './feature';
@@ -39,6 +40,8 @@ utils.deleteSessionFile();
3940

4041
export function activate(context: vscode.ExtensionContext): void {
4142

43+
checkForUpdatedVersion(context);
44+
4245
vscode.languages.setLanguageConfiguration(
4346
PowerShellLanguageId,
4447
{
@@ -125,6 +128,43 @@ export function activate(context: vscode.ExtensionContext): void {
125128
}
126129
}
127130

131+
function checkForUpdatedVersion(context: vscode.ExtensionContext) {
132+
133+
const showReleaseNotes = "Show Release Notes";
134+
const powerShellExtensionVersionKey = 'powerShellExtensionVersion';
135+
136+
var extensionVersion: string =
137+
vscode
138+
.extensions
139+
.getExtension("ms-vscode.PowerShell")
140+
.packageJSON
141+
.version;
142+
143+
var storedVersion = context.globalState.get(powerShellExtensionVersionKey);
144+
145+
if (!storedVersion) {
146+
// TODO: Prompt to show User Guide for first-time install
147+
}
148+
else if (extensionVersion !== storedVersion) {
149+
vscode
150+
.window
151+
.showInformationMessage(
152+
`The PowerShell extension has been updated to version ${extensionVersion}!`,
153+
showReleaseNotes)
154+
.then(choice => {
155+
if (choice === showReleaseNotes) {
156+
vscode.commands.executeCommand(
157+
'markdown.showPreview',
158+
vscode.Uri.file(path.resolve(__dirname, "../CHANGELOG.md")));
159+
}
160+
});
161+
}
162+
163+
context.globalState.update(
164+
powerShellExtensionVersionKey,
165+
extensionVersion);
166+
}
167+
128168
export function deactivate(): void {
129169
// Clean up all extension features
130170
extensionFeatures.forEach(feature => {

0 commit comments

Comments
 (0)