diff options
| author | ST-DDT <[email protected]> | 2024-12-02 10:34:57 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-12-02 10:34:57 +0100 |
| commit | 7d59cd9bfbfebaccc93811a50cc698e46e6c862b (patch) | |
| tree | 0d9fca812dcb3a0a43a5b7991a23150cf9262257 /scripts/generate-locales.ts | |
| parent | 176d4300366b0481fbc01f2da3faad104d626dc9 (diff) | |
| download | faker-7d59cd9bfbfebaccc93811a50cc698e46e6c862b.tar.xz faker-7d59cd9bfbfebaccc93811a50cc698e46e6c862b.zip | |
infra(unicorn): prefer-export-from (#3272)
Diffstat (limited to 'scripts/generate-locales.ts')
| -rw-r--r-- | scripts/generate-locales.ts | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/scripts/generate-locales.ts b/scripts/generate-locales.ts index 13fe70fd..b4bc2311 100644 --- a/scripts/generate-locales.ts +++ b/scripts/generate-locales.ts @@ -427,10 +427,14 @@ async function normalizeLocaleFile(filePath: string, definitionKey: string) { const locales = await readdir(pathLocales); removeIndexTs(locales); +// src/locale/index.ts (Faker Imports and Exports) let localeIndexImports = ''; let localeIndexExportsIndividual = ''; let localeIndexExportsGrouped = ''; +// src/locales/index.ts (Locale Data Imports and Exports) let localesIndexImports = ''; +let localesIndexExportsIndividual = ''; +let localesIndexExportsGrouped = ''; let localizationLocales = '| Locale | Name | Faker |\n| :--- | :--- | :--- |\n'; const promises: Array<Promise<unknown>> = []; @@ -459,9 +463,11 @@ for (const locale of locales) { )}`; localeIndexImports += `import { faker as ${localizedFaker} } from './${locale}';\n`; - localeIndexExportsIndividual += ` ${localizedFaker},\n`; + localeIndexExportsIndividual += `export { faker as ${localizedFaker} } from './${locale}';\n`; localeIndexExportsGrouped += ` ${locale}: ${localizedFaker},\n`; localesIndexImports += `import { default as ${locale} } from './${locale}';\n`; + localesIndexExportsIndividual += `export { default as ${locale} } from './${locale}';\n`; + localesIndexExportsGrouped += ` ${locale},\n`; localizationLocales += `| \`${locale}\` | ${localeTitle} | \`${localizedFaker}\` |\n`; promises.push( @@ -484,9 +490,7 @@ let localeIndexContent = ` ${localeIndexImports} - export { ${localeIndexExportsIndividual} - }; export const allFakers = { ${localeIndexExportsGrouped} @@ -503,9 +507,11 @@ let localesIndexContent = ` ${localesIndexImports} - export { ${locales.join(',')} }; + ${localesIndexExportsIndividual} - export const allLocales = { ${locales.join(',')} }; + export const allLocales = { + ${localesIndexExportsGrouped} + } as const; `; localesIndexContent = await formatTypescript(localesIndexContent); |
