Skip to content

Commit

Permalink
fix: use minimatch for more expected matching results
Browse files Browse the repository at this point in the history
  • Loading branch information
shetzel committed Nov 30, 2023
1 parent 0c9d568 commit e2618bf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/collections/componentSetBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import * as path from 'node:path';
import { StateAggregator, Logger, SfError, Messages } from '@salesforce/core';
import * as fs from 'graceful-fs';
import * as minimatch from 'minimatch';
import { ComponentSet } from '../collections';
import { RegistryAccess } from '../registry';
import { FileProperties } from '../client';
Expand Down Expand Up @@ -134,7 +135,8 @@ export class ComponentSetBuilder {
})
.getSourceComponents()
.toArray()
.filter((cs) => new RegExp(splitEntry[1]).test(cs.fullName))
// using minimatch versus RegExp provides better (more expected) matching results
.filter((cs) => minimatch(cs.fullName, splitEntry[1]))
.map((match) => {
compSetFilter.add(match);
componentSet?.add(match);
Expand Down Expand Up @@ -179,7 +181,8 @@ export class ComponentSetBuilder {
componentFilter = (component: Partial<FileProperties>): boolean => {
if (component.type && component.fullName) {
const mdMapEntry = mdMap.get(component.type);
return !!mdMapEntry && mdMapEntry.some((mdName) => new RegExp(mdName).test(component.fullName as string));
// using minimatch versus RegExp provides better (more expected) matching results
return !!mdMapEntry && mdMapEntry.some((mdName) => minimatch(component.fullName as string, mdName));
}
return false;
};
Expand Down

2 comments on commit e2618bf

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: e2618bf Previous: 0c9d568 Ratio
eda-componentSetCreate-linux 230 ms 200 ms 1.15
eda-sourceToMdapi-linux 5197 ms 4937 ms 1.05
eda-sourceToZip-linux 4894 ms 3904 ms 1.25
eda-mdapiToSource-linux 2971 ms 3085 ms 0.96
lotsOfClasses-componentSetCreate-linux 385 ms 374 ms 1.03
lotsOfClasses-sourceToMdapi-linux 6447 ms 5767 ms 1.12
lotsOfClasses-sourceToZip-linux 5963 ms 5738 ms 1.04
lotsOfClasses-mdapiToSource-linux 3480 ms 3428 ms 1.02
lotsOfClassesOneDir-componentSetCreate-linux 667 ms 632 ms 1.06
lotsOfClassesOneDir-sourceToMdapi-linux 9314 ms 9019 ms 1.03
lotsOfClassesOneDir-sourceToZip-linux 8295 ms 8250 ms 1.01
lotsOfClassesOneDir-mdapiToSource-linux 6055 ms 6190 ms 0.98

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: e2618bf Previous: 0c9d568 Ratio
eda-componentSetCreate-win32 428 ms 418 ms 1.02
eda-sourceToMdapi-win32 7373 ms 6788 ms 1.09
eda-sourceToZip-win32 5745 ms 5811 ms 0.99
eda-mdapiToSource-win32 5903 ms 6056 ms 0.97
lotsOfClasses-componentSetCreate-win32 902 ms 944 ms 0.96
lotsOfClasses-sourceToMdapi-win32 10573 ms 10733 ms 0.99
lotsOfClasses-sourceToZip-win32 7510 ms 7949 ms 0.94
lotsOfClasses-mdapiToSource-win32 7573 ms 7431 ms 1.02
lotsOfClassesOneDir-componentSetCreate-win32 1473 ms 1501 ms 0.98
lotsOfClassesOneDir-sourceToMdapi-win32 16878 ms 16765 ms 1.01
lotsOfClassesOneDir-sourceToZip-win32 11231 ms 13000 ms 0.86
lotsOfClassesOneDir-mdapiToSource-win32 13294 ms 15529 ms 0.86

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.