2015-11-24 21:44:20 +00:00
|
|
|
'use strict';
|
|
|
|
|
2015-11-24 18:59:42 +00:00
|
|
|
import { extensions, Extension } from 'vscode';
|
|
|
|
|
|
|
|
export class ExtensionManifestReader {
|
|
|
|
constructor(extensionId: string) {
|
|
|
|
this._extension = extensions.getExtension(extensionId);
|
2015-11-24 22:06:24 +00:00
|
|
|
this.refresh();
|
2015-11-24 18:59:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private _extension: Extension<any>
|
|
|
|
|
|
|
|
name: string;
|
|
|
|
version: string;
|
|
|
|
publisher: string;
|
|
|
|
displayName: string;
|
|
|
|
description: string;
|
|
|
|
categories: string[];
|
|
|
|
keywords: string[];
|
|
|
|
icon: string;
|
|
|
|
|
|
|
|
private _checkPropertyExists(propertyName: string) {
|
|
|
|
for (let property in this) {
|
|
|
|
if (property === propertyName) return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
refresh(): void {
|
2015-11-24 22:06:24 +00:00
|
|
|
let manifest = this._extension.packageJSON;
|
2015-11-24 18:59:42 +00:00
|
|
|
|
|
|
|
for (let property in manifest)
|
|
|
|
{
|
|
|
|
if (this._checkPropertyExists(property)) {
|
|
|
|
this[property] = manifest[property];
|
|
|
|
}
|
|
|
|
}
|
2015-11-24 22:06:24 +00:00
|
|
|
|
|
|
|
this.displayName = manifest.displayName;
|
2015-11-24 18:59:42 +00:00
|
|
|
}
|
|
|
|
}
|