Skip to content

Commit

Permalink
Merge branch 'master' into chore/simplify-variable-init
Browse files Browse the repository at this point in the history
  • Loading branch information
derberg authored Oct 14, 2024
2 parents e527716 + 254b072 commit 05942c4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/generator/lib/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class Generator {
Object.defineProperty(this.templateParams, key, {
enumerable: true,
get() {
if (!self.templateConfig.parameters || !self.templateConfig.parameters[key]) {
if (!self.templateConfig.parameters?.[key]) {
throw new Error(`Template parameter "${key}" has not been defined in the package.json file under generator property. Please make sure it's listed there before you use it in your template.`);
}
return templateParams[key];
Expand Down
2 changes: 1 addition & 1 deletion apps/generator/lib/templateConfigValidator.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function getParamSuggestion(wrongParam, configParams) {
* @param {Object} templateParams All parameters provided to generator
*/
function isProvidedParameterSupported(configParams, templateParams) {
const wrongParams = Object.keys(templateParams || {}).filter(key => !configParams || !configParams[key]);
const wrongParams = Object.keys(templateParams || {}).filter(key => !configParams?.[key]);

if (!wrongParams.length) return;
if (!configParams) throw new Error('This template doesn\'t have any params.');
Expand Down

0 comments on commit 05942c4

Please sign in to comment.