提交 79de645f 编写于 作者: S Sandeep Somavarapu

filter invalid extensions

上级 61327846
...@@ -83,29 +83,45 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten ...@@ -83,29 +83,45 @@ export class WebExtensionsScannerService extends Disposable implements IWebExten
*/ */
private getStaticExtensions(builtin: boolean): IScannedExtension[] { private getStaticExtensions(builtin: boolean): IScannedExtension[] {
const staticExtensions = this.environmentService.options && Array.isArray(this.environmentService.options.staticExtensions) ? this.environmentService.options.staticExtensions : []; const staticExtensions = this.environmentService.options && Array.isArray(this.environmentService.options.staticExtensions) ? this.environmentService.options.staticExtensions : [];
return ( const result: IScannedExtension[] = [];
staticExtensions for (const e of staticExtensions) {
.filter(e => Boolean(e.isBuiltin) === builtin) if (Boolean(e.isBuiltin) === builtin) {
.map(e => ({ const scannedExtension = this.parseStaticExtension(e, builtin);
identifier: { id: getGalleryExtensionId(e.packageJSON.publisher, e.packageJSON.name) }, if (scannedExtension) {
location: e.extensionLocation, result.push(scannedExtension);
type: e.isBuiltin ? ExtensionType.System : ExtensionType.User, }
packageJSON: e.packageJSON, }
})) }
); return result;
} }
private async readDefaultExtensions(): Promise<IScannedExtension[]> { private async readDefaultExtensions(): Promise<IScannedExtension[]> {
const defaultUserWebExtensions = await this.readDefaultUserWebExtensions(); const defaultUserWebExtensions = await this.readDefaultUserWebExtensions();
const extensions = defaultUserWebExtensions.map(e => ({ const extensions: IScannedExtension[] = [];
identifier: { id: getGalleryExtensionId(e.packageJSON.publisher, e.packageJSON.name) }, for (const e of defaultUserWebExtensions) {
location: e.extensionLocation, const scannedExtension = this.parseStaticExtension(e, false);
type: ExtensionType.User, if (scannedExtension) {
packageJSON: e.packageJSON, extensions.push(scannedExtension);
})); }
}
return extensions.concat(this.getStaticExtensions(false)); return extensions.concat(this.getStaticExtensions(false));
} }
private parseStaticExtension(e: IStaticExtension, builtin: boolean): IScannedExtension | null {
try {
return {
identifier: { id: getGalleryExtensionId(e.packageJSON.publisher, e.packageJSON.name) },
location: e.extensionLocation,
type: builtin ? ExtensionType.System : ExtensionType.User,
packageJSON: e.packageJSON,
};
} catch (error) {
this.logService.error(`Error while parsing extension ${e.extensionLocation.toString()}`);
this.logService.error(error);
}
return null;
}
private async readDefaultUserWebExtensions(): Promise<IStaticExtension[]> { private async readDefaultUserWebExtensions(): Promise<IStaticExtension[]> {
const result: IStaticExtension[] = []; const result: IStaticExtension[] = [];
const defaultUserWebExtensions = this.configurationService.getValue<{ location: string }[]>('_extensions.defaultUserWebExtensions') || []; const defaultUserWebExtensions = this.configurationService.getValue<{ location: string }[]>('_extensions.defaultUserWebExtensions') || [];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册