|
6 | 6 |
|
7 | 7 | import vscode = require('vscode');
|
8 | 8 | import utils = require('./utils');
|
| 9 | +import path = require('path'); |
9 | 10 | import Settings = require('./settings');
|
10 | 11 | import { Logger, LogLevel } from './logging';
|
11 | 12 | import { IFeature } from './feature';
|
@@ -39,6 +40,8 @@ utils.deleteSessionFile();
|
39 | 40 |
|
40 | 41 | export function activate(context: vscode.ExtensionContext): void {
|
41 | 42 |
|
| 43 | + checkForUpdatedVersion(context); |
| 44 | + |
42 | 45 | vscode.languages.setLanguageConfiguration(
|
43 | 46 | PowerShellLanguageId,
|
44 | 47 | {
|
@@ -125,6 +128,43 @@ export function activate(context: vscode.ExtensionContext): void {
|
125 | 128 | }
|
126 | 129 | }
|
127 | 130 |
|
| 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 | + |
128 | 168 | export function deactivate(): void {
|
129 | 169 | // Clean up all extension features
|
130 | 170 | extensionFeatures.forEach(feature => {
|
|
0 commit comments