From a26f8293997973042b5ab35f10a489cc6bc750d9 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Tue, 24 Nov 2015 17:06:24 -0500 Subject: [PATCH] Update Notifier Tweaks --- src/main.ts | 3 ++- src/utils/ManifestUtils.ts | 5 ++++- src/utils/UpdateNotifier.ts | 10 +++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main.ts b/src/main.ts index 7192ece..9d7473f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,10 +3,11 @@ import { commands, ExtensionContext } from 'vscode'; import { formatXml, linearizeXml } from './features/xmlFormatting'; import { evaluateXPath } from './features/xmlXPathEngine'; +import { checkForUpdates } from './utils/UpdateNotifier'; export function activate(ctx: ExtensionContext) { // check for update - //... + checkForUpdates(); // register palette commands ctx.subscriptions.push(commands.registerTextEditorCommand('xmltools.formatXml', formatXml)); diff --git a/src/utils/ManifestUtils.ts b/src/utils/ManifestUtils.ts index 3b22efe..bb708c7 100644 --- a/src/utils/ManifestUtils.ts +++ b/src/utils/ManifestUtils.ts @@ -5,6 +5,7 @@ import { extensions, Extension } from 'vscode'; export class ExtensionManifestReader { constructor(extensionId: string) { this._extension = extensions.getExtension(extensionId); + this.refresh(); } private _extension: Extension @@ -27,7 +28,7 @@ export class ExtensionManifestReader { } refresh(): void { - let manifest: any = this._extension.packageJSON; + let manifest = this._extension.packageJSON; for (let property in manifest) { @@ -35,5 +36,7 @@ export class ExtensionManifestReader { this[property] = manifest[property]; } } + + this.displayName = manifest.displayName; } } \ No newline at end of file diff --git a/src/utils/UpdateNotifier.ts b/src/utils/UpdateNotifier.ts index 078b0b9..74e51e0 100644 --- a/src/utils/UpdateNotifier.ts +++ b/src/utils/UpdateNotifier.ts @@ -6,9 +6,9 @@ import { ExtensionManifestReader } from './ManifestUtils'; let req = require('request'); let semver = require('semver'); -export function checkForUpdates() { +export function checkForUpdates() { let manifestReader: ExtensionManifestReader = new ExtensionManifestReader('DotJoshJohnson.xml'); - let currentVersion = manifestReader.version; + let currentVersion = '0.0.0';//manifestReader.version; // use the GitHub api to determine the latest released version let url = 'https://api.github.com/repos/DotJoshJohnson/vscode-xml/releases/latest'; @@ -24,7 +24,7 @@ export function checkForUpdates() { req(options, (error, response, body) => { if (!error && response.statusCode == 200) { let release = JSON.parse(body); - let latestVersion = release.name.substring(1); // the telease/tag is prefixed with a "v" + let latestVersion = release.name.substring(1); // the release/tag is prefixed with a "v" if (!release.draft && semver.gt(latestVersion, currentVersion)) { let updateNowLabel = 'Update Now'; @@ -35,5 +35,9 @@ export function checkForUpdates() { }); } } + + else { + console.log('XML Tools: Failed to get latest release information from GitHub.'); + } }); } \ No newline at end of file