Filter extensions by category (#77306)

* Revert commit change

* Revert commit change

* Revert commit change

* Revert commit change

* Revert commit change

* Revert commit change

* Provide option to filter by category

* ignore casing

* Remove unwanted build change
This commit is contained in:
Logan Ramos
2019-07-23 07:29:35 -07:00
committed by GitHub
parent 3512f9e82c
commit b4734e8524
4 changed files with 15 additions and 3 deletions

View File

@@ -86,7 +86,7 @@ export class Main {
await this.setInstallSource(argv['install-source']);
} else if (argv['list-extensions']) {
await this.listExtensions(!!argv['show-versions']);
await this.listExtensions(!!argv['show-versions'], argv['category']);
} else if (argv['install-extension']) {
const arg = argv['install-extension'];
@@ -110,8 +110,17 @@ export class Main {
return writeFile(this.environmentService.installSourcePath, installSource.slice(0, 30));
}
private async listExtensions(showVersions: boolean): Promise<void> {
const extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
private async listExtensions(showVersions: boolean, category?: string): Promise<void> {
let extensions = await this.extensionManagementService.getInstalled(ExtensionType.User);
if (category) {
extensions = extensions.filter(e => {
if (e.manifest.categories) {
const lowerCaseCategories: string[] = e.manifest.categories.map(c => c.toLowerCase());
return lowerCaseCategories.indexOf(category.toLowerCase()) > -1;
}
return false;
});
}
extensions.forEach(e => console.log(getId(e.manifest, showVersions)));
}