From 351608a718b724ffeb6f93183d3eb4b49f227997 Mon Sep 17 00:00:00 2001 From: Josh Johnson Date: Tue, 24 Nov 2015 13:59:42 -0500 Subject: [PATCH] Add ExtensionManifestReader --- src/utils/ManifestUtils.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/utils/ManifestUtils.ts diff --git a/src/utils/ManifestUtils.ts b/src/utils/ManifestUtils.ts new file mode 100644 index 0000000..51afd58 --- /dev/null +++ b/src/utils/ManifestUtils.ts @@ -0,0 +1,37 @@ +import { extensions, Extension } from 'vscode'; + +export class ExtensionManifestReader { + constructor(extensionId: string) { + this._extension = extensions.getExtension(extensionId); + } + + private _extension: Extension + + 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]; + } + } + } +} \ No newline at end of file