Skip to content

Commit

Permalink
Better optmize the file extensions glob
Browse files Browse the repository at this point in the history
  • Loading branch information
iclanton committed Nov 10, 2020
1 parent 4945b79 commit 113bbea
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions apps/heft/src/plugins/CopyFilesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,26 @@ export class CopyFilesPlugin implements IHeftPlugin {
}

private _getIncludedGlobPatterns(copyConfiguration: IExtendedSharedCopyConfiguration): string[] {
// Glob extensions with a specific glob to increase perf
const patternsToGlob: Set<string> = new Set<string>();

// Glob file extensions with a specific glob to increase perf
const escapedFileExtensions: Set<string> = new Set<string>();
for (const fileExtension of copyConfiguration.fileExtensions || []) {
const escapedExtension: string = glob.escapePath(fileExtension);
patternsToGlob.add(`**/*${escapedExtension}`);
let escapedFileExtension: string;
if (fileExtension.charAt(0) === '.') {
escapedFileExtension = fileExtension.substr(1);
} else {
escapedFileExtension = fileExtension;
}

escapedFileExtension = glob.escapePath(escapedFileExtension);
escapedFileExtensions.add(escapedFileExtension);
}

if (escapedFileExtensions.size > 1) {
patternsToGlob.add(`**/*.{${Array.from(escapedFileExtensions).join(',')}}`);
} else if (escapedFileExtensions.size === 1) {
patternsToGlob.add(`**/*.${Array.from(escapedFileExtensions)[0]}`);
}

// Now include the other globs as well
Expand Down

0 comments on commit 113bbea

Please sign in to comment.