diff --git a/src/main.ts b/src/main.ts index 4d93538bfe..698ab251fa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import vscode = require('vscode'); import utils = require('./utils'); +import path = require('path'); import Settings = require('./settings'); import { Logger, LogLevel } from './logging'; import { IFeature } from './feature'; @@ -39,6 +40,8 @@ utils.deleteSessionFile(); export function activate(context: vscode.ExtensionContext): void { + checkForUpdatedVersion(context); + vscode.languages.setLanguageConfiguration( PowerShellLanguageId, { @@ -125,6 +128,43 @@ export function activate(context: vscode.ExtensionContext): void { } } +function checkForUpdatedVersion(context: vscode.ExtensionContext) { + + const showReleaseNotes = "Show Release Notes"; + const powerShellExtensionVersionKey = 'powerShellExtensionVersion'; + + var extensionVersion: string = + vscode + .extensions + .getExtension("ms-vscode.PowerShell") + .packageJSON + .version; + + var storedVersion = context.globalState.get(powerShellExtensionVersionKey); + + if (!storedVersion) { + // TODO: Prompt to show User Guide for first-time install + } + else if (extensionVersion !== storedVersion) { + vscode + .window + .showInformationMessage( + `The PowerShell extension has been updated to version ${extensionVersion}!`, + showReleaseNotes) + .then(choice => { + if (choice === showReleaseNotes) { + vscode.commands.executeCommand( + 'markdown.showPreview', + vscode.Uri.file(path.resolve(__dirname, "../CHANGELOG.md"))); + } + }); + } + + context.globalState.update( + powerShellExtensionVersionKey, + extensionVersion); +} + export function deactivate(): void { // Clean up all extension features extensionFeatures.forEach(feature => {