(absolutePath: string)
| 64 | * @throws {InvalidGoogleSyncConfigError} If the configuration is invalid. |
| 65 | */ |
| 66 | export async function getGoogleSyncConfig(absolutePath: string): Promise<{ |
| 67 | ngMatchFn: SyncFileMatchFn; |
| 68 | separateMatchFn: SyncFileMatchFn; |
| 69 | config: GoogleSyncConfig; |
| 70 | }> { |
| 71 | const content = await fs.promises.readFile(absolutePath, 'utf8'); |
| 72 | const errors: jsonc.ParseError[] = []; |
| 73 | const config = jsonc.parse(content, errors) as GoogleSyncConfig; |
| 74 | if (errors.length !== 0) { |
| 75 | throw new InvalidGoogleSyncConfigError( |
| 76 | `Google Sync Configuration is invalid: ` + |
| 77 | errors.map((e) => jsonc.printParseErrorCode(e.error)).join('\n'), |
| 78 | ); |
| 79 | } |
| 80 | const matchFns = transformConfigIntoMatcher(config); |
| 81 | return { |
| 82 | config, |
| 83 | ngMatchFn: matchFns.ngSyncMatchFn, |
| 84 | separateMatchFn: matchFns.separateSyncMatchFn, |
| 85 | }; |
| 86 | } |
no test coverage detected