(config: GoogleSyncConfig)
| 37 | |
| 38 | /** Transforms the given sync configuration into a file match function. */ |
| 39 | export 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. |
no outgoing calls
no test coverage detected