MCPcopy Create free account
hub / github.com/angular/dev-infra / transformConfigIntoMatcher

Function transformConfigIntoMatcher

ng-dev/utils/g3-sync-config.ts:39–59  ·  view source on GitHub ↗
(config: GoogleSyncConfig)

Source from the content-addressed store, hash-verified

37
38/** Transforms the given sync configuration into a file match function. */
39export function transformConfigIntoMatcher(config: GoogleSyncConfig): {
40 ngSyncMatchFn: SyncFileMatchFn;
41 separateSyncMatchFn: SyncFileMatchFn;
42} {
43 const syncedFilePatterns = config.syncedFilePatterns.map((p) => new Minimatch(p));
44 const alwaysExternalFilePatterns = config.alwaysExternalFilePatterns.map((p) => new Minimatch(p));
45 const separateFilePatterns = config.separateFilePatterns.map((p) => new Minimatch(p));
46
47 // match everything that needs to be synced except external and separate sync files
48 const ngSyncMatchFn = (projectRelativePath: string) =>
49 syncedFilePatterns.some((p) => p.match(projectRelativePath)) &&
50 alwaysExternalFilePatterns.every((p) => !p.match(projectRelativePath)) &&
51 separateFilePatterns.every((p) => !p.match(projectRelativePath));
52
53 // match only files that need to be synced separately
54 const separateSyncMatchFn = (projectRelativePath: string) =>
55 separateFilePatterns.some((p) => p.match(projectRelativePath)) &&
56 alwaysExternalFilePatterns.every((p) => !p.match(projectRelativePath));
57
58 return {ngSyncMatchFn, separateSyncMatchFn};
59}
60
61/**
62 * Reads the configuration file from the given path.

Callers 1

getGoogleSyncConfigFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected