(root: string, files: string[], jsonPath: string)
| 49 | } |
| 50 | |
| 51 | function getLocalesFromJson(root: string, files: string[], jsonPath: string) { |
| 52 | return files.flatMap(file => { |
| 53 | const json = JSON.parse(readFileSync(join(root, file), 'utf8')) |
| 54 | const value = getPathValue(json, jsonPath) |
| 55 | if (!value || typeof value !== 'object' || Array.isArray(value)) { |
| 56 | throw new Error(`JSON path "${jsonPath}" must resolve to an object`) |
| 57 | } |
| 58 | return Object.keys(value).filter(isCanonicalLocale) |
| 59 | }) |
| 60 | } |
| 61 | |
| 62 | function formatLocales(variable: string, locales: string[]): string { |
| 63 | const lines = [ |
no test coverage detected