fix: fixed minor bug with utils/file exists() function #683
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.
Description
While investigating an issue I had with the JSON loader, I found that the exists function does not work as intended. The
node:fs/promises
stat()
function resolves with the stats data if the file exists, but the promise is rejected when the file does not exist, so the function never really returnsfalse
, swallowing the errors forgetFiles
in theparseTranslations()
function as well as thenew I18nError
at the top ofparseTranslations()
after theexists()
check.I also came across this line
So I also switched the implementation to use
fs.access
instead offs.stat
.Linked Issues
Additional context
Quick view of the simple tests that I added:
and with the original implementation:

here are the test results:

and with the updated implementation:

here are the test results:
