Skip to content

Add version update notification #624

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

Merged
merged 1 commit into from
Mar 28, 2017
Merged
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
40 changes: 40 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -39,6 +40,8 @@ utils.deleteSessionFile();

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

checkForUpdatedVersion(context);

vscode.languages.setLanguageConfiguration(
PowerShellLanguageId,
{
Expand Down Expand Up @@ -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 => {
Expand Down