Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i18n: Improve handling of file existence check in compileCatalog #1833

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Samk13
Copy link
Member

@Samk13 Samk13 commented Oct 1, 2024

❤️ Thank you for your contribution!

Description

  • Add a check for the existence of the file before attempting to read it
  • Log an error message if the file does not exist
  • Improve readability by extracting the file existence check into a function

Fix this error where it will stop execution if one of the languages mises .po file:

npm run compile_catalog

> compile_catalog
> node ./scripts/compileCatalog.js

node:fs:573
  return binding.open(
                 ^

Error: ENOENT: no such file or directory, open './messages/en/messages.po'
    at Object.openSync (node:fs:573:18)
    at readFileSync (node:fs:452:35)
    at Object.<anonymous> (/home/user/INVENIO/issues/invenio-rdm-records/invenio_rdm_records/assets/semantic-ui/translations/invenio_rdm_records/scripts/compileCatalog.js:36:7)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Module._load (node:internal/modules/cjs/loader:1024:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)
    at node:internal/main/run_main_module:28:49 {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: './messages/en/messages.po'
}

Node.js v20.13.1

After:

npm run compile_catalog

> compile_catalog
> node ./scripts/compileCatalog.js

File not found: ./messages/en/messages.po for language en

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

*  Add a check for the existence of the file before attempting to read it
*  Log an error message if the file does not exist
* Improve readability by extracting the file existence check into a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant