add getChangelog method to IExtension and its impl

This commit is contained in:
XVincentX 2016-09-14 09:31:00 +02:00
parent 3027fff306
commit 50b7571b0a
No known key found for this signature in database
GPG key ID: D618C95BD28F3AE0
2 changed files with 25 additions and 0 deletions

View file

@ -42,6 +42,7 @@ export interface IExtension {
telemetryData: any;
getManifest(): TPromise<IExtensionManifest>;
getReadme(): TPromise<string>;
getChangelog() : TPromise<string>;
}
export const SERVICE_ID = 'extensionsWorkbenchService';

View file

@ -94,6 +94,14 @@ class Extension implements IExtension {
return this.gallery && this.gallery.assets.readme;
}
get changelogUrl(): string {
if (this.local && this.local.changelogUrl) {
return this.local.changelogUrl;
}
return ''; // Hopefully we will change this once the gallery will support that.
}
get iconUrl(): string {
return this.localIconUrl || this.galleryIconUrl || this.defaultIconUrl;
}
@ -178,6 +186,22 @@ class Extension implements IExtension {
return this.galleryService.getAsset(readmeUrl).then(asText);
}
getChangelog() : TPromise<string> {
const changelogUrl = this.local && this.local.changelogUrl ? this.local.changelogUrl : '';
if (!changelogUrl) {
return TPromise.wrapError('not available');
}
const uri = URI.parse(changelogUrl);
if (uri.scheme === 'file') {
return readFile(uri.fsPath, 'utf8');
}
return TPromise.wrapError('not available');
}
}
function stripVersion(id: string): string {