37 lines
753 B
TypeScript
37 lines
753 B
TypeScript
|
import { extensions, Extension } from 'vscode';
|
||
|
|
||
|
export class ExtensionManifestReader {
|
||
|
constructor(extensionId: string) {
|
||
|
this._extension = extensions.getExtension(extensionId);
|
||
|
}
|
||
|
|
||
|
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 {
|
||
|
let manifest: any = this._extension.packageJSON;
|
||
|
|
||
|
for (let property in manifest)
|
||
|
{
|
||
|
if (this._checkPropertyExists(property)) {
|
||
|
this[property] = manifest[property];
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|