Fix Manifest Reader

This commit is contained in:
Josh Johnson 2015-11-24 18:48:26 -05:00
parent a26f829399
commit e24a560066
2 changed files with 10 additions and 18 deletions

View File

@ -19,24 +19,16 @@ export class ExtensionManifestReader {
keywords: string[]; keywords: string[];
icon: string; icon: string;
private _checkPropertyExists(propertyName: string) {
for (let property in this) {
if (property === propertyName) return true;
}
return false;
}
refresh(): void { refresh(): void {
let manifest = this._extension.packageJSON; let manifest = this._extension.packageJSON;
for (let property in manifest) this.name = manifest.name;
{ this.version = manifest.version;
if (this._checkPropertyExists(property)) { this.publisher = manifest.publisher;
this[property] = manifest[property];
}
}
this.displayName = manifest.displayName; this.displayName = manifest.displayName;
this.description = manifest.description;
this.categories = manifest.categories;
this.keywords = manifest.keywords;
this.icon = manifest.icon;
} }
} }

View File

@ -8,7 +8,7 @@ let semver = require('semver');
export function checkForUpdates() { export function checkForUpdates() {
let manifestReader: ExtensionManifestReader = new ExtensionManifestReader('DotJoshJohnson.xml'); let manifestReader: ExtensionManifestReader = new ExtensionManifestReader('DotJoshJohnson.xml');
let currentVersion = '0.0.0';//manifestReader.version; let currentVersion = manifestReader.version;
// use the GitHub api to determine the latest released version // use the GitHub api to determine the latest released version
let url = 'https://api.github.com/repos/DotJoshJohnson/vscode-xml/releases/latest'; let url = 'https://api.github.com/repos/DotJoshJohnson/vscode-xml/releases/latest';
@ -27,10 +27,10 @@ export function checkForUpdates() {
let latestVersion = release.name.substring(1); // the release/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)) { if (!release.draft && semver.gt(latestVersion, currentVersion)) {
let updateNowLabel = 'Update Now'; let updateNowLabel = 'Open Extension Manager';
window.showInformationMessage(`Version ${latestVersion} of the ${manifestReader.displayName} extension is available.`, updateNowLabel).then((clicked) => { window.showInformationMessage(`Version ${latestVersion} of the ${manifestReader.displayName} extension is available.`, updateNowLabel).then((clicked) => {
if (clicked == updateNowLabel) { if (clicked == updateNowLabel) {
commands.executeCommand('workbench.extensions.action.installExtension', manifestReader.displayName); commands.executeCommand('workbench.extensions.action.listExtensions', manifestReader.displayName);
} }
}); });
} }