fix: handle missing or broken locales main index files#478
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## main #478 +/- ##
==========================================
- Coverage 99.34% 99.34% -0.01%
==========================================
Files 1919 1919
Lines 176291 176291
Branches 898 898
==========================================
- Hits 175132 175131 -1
- Misses 1103 1104 +1
Partials 56 56
|
Shinigami92
approved these changes
Feb 12, 2022
prisis
approved these changes
Feb 14, 2022
demipel8
pushed a commit
to demipel8/faker
that referenced
this pull request
Mar 11, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While preparing #477 I encountered the issue, that I renamed the files, but did not fix the imports (as that is supposed to be done by the
generate:localesscript instead.However, the script failed to execute, because it tries to import the locale to read it's title and separator.
$ pnpm run generate:locales > @faker-js/faker@6.0.0-alpha.6 generate:locales ~/git/Faker/faker > esno ./scripts/generateLocales.ts Error: Cannot find module './bicycle' Require stack: - ~/git/Faker/faker/src/locales/en/vehicle/index.ts - ~/git/Faker/faker/src/locales/en/index.ts - ~/git/Faker/faker/scripts/generateLocales.ts at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15) at Function.Module._load (node:internal/modules/cjs/loader:778:27) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at Object.<anonymous> (~/git/Faker/faker/src/locales/en/vehicle/index.ts:6:21) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Module._compile (~/git/Faker/faker/node_modules/.pnpm/esbuild-register@3.3.2_esbuild@0.14.21/node_modules/esbuild-register/dist/node.js:2258:26) at Module._extensions..js (node:internal/modules/cjs/loader:1153:10) at Object.newLoader [as .ts] (~/git/Faker/faker/node_modules/.pnpm/esbuild-register@3.3.2_esbuild@0.14.21/node_modules/esbuild-register/dist/node.js:2262:9) at Module.load (node:internal/modules/cjs/loader:981:32) { code: 'MODULE_NOT_FOUND', requireStack: [ '~/git/Faker/faker/src/locales/en/vehicle/index.ts', '~/git/Faker/faker/src/locales/en/index.ts', '~/git/Faker/faker/scripts/generateLocales.ts' ] }This PR prevents these kind of issues, by adding two fallback layers.
With this new version it is possible to remove or invalidate all
index.tsfiles fromsrc/localesand regenerate them (without the original title though).