diff --git a/apps/generator/lib/generator.js b/apps/generator/lib/generator.js index cb4ffe950..8b2592a6f 100644 --- a/apps/generator/lib/generator.js +++ b/apps/generator/lib/generator.js @@ -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]; diff --git a/apps/generator/lib/templateConfigValidator.js b/apps/generator/lib/templateConfigValidator.js index 3b57ef759..9e075b98b 100644 --- a/apps/generator/lib/templateConfigValidator.js +++ b/apps/generator/lib/templateConfigValidator.js @@ -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.');