-
-
Notifications
You must be signed in to change notification settings - Fork 381
Description
Describe the bug.
The getTemplate function in apps/generator/lib/templates/bakedInTemplates.js does not handle the case where a template name does not exist in the baked-in templates list.
According to the JSDoc:
The function should return undefined when the template is not found.
However, when a non-existing template name is passed, the function throws a TypeError due to attempting to access .name on undefined.
Expected behavior
When a template is not found, the function should:
Either return undefined (as documented),
Or throw a meaningful, explicit error such as:
throw new Error(Core template "${templateName}" not found.);
It should not throw an unintended TypeError.
Screenshots
How to Reproduce
Navigate to:
generator/apps/generator/lib/templates
Start Node REPL:
node
Run:
const baked = require('./bakedInTemplates');
baked.getTemplate('this-template-does-not-exist');
Observe the crash:
TypeError: Cannot read properties of undefined (reading 'name')
🖥️ Device Information [optional]
- Operating System (OS):Windows11
- Browser:Brave
- Browser Version:
👀 Have you checked for similar open issues?
- I checked and didn't find similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue ?
Yes I am willing to submit a PR!