Skip to content

Commit

Permalink
Merge branch 'master' into fix/nested-template-literals
Browse files Browse the repository at this point in the history
  • Loading branch information
derberg authored Oct 15, 2024
2 parents e4afaa6 + 298479a commit fcbecd3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 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
4 changes: 2 additions & 2 deletions apps/generator/test/renderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ jest.mock('@asyncapi/generator-react-sdk');

describe('React renderer', () => {
describe('saveRenderedReactContent', () => {
let util = undefined;
let AsyncReactSDK = undefined;
let util;
let AsyncReactSDK;
beforeAll(() => {
util = require('../lib/utils');
AsyncReactSDK = require('@asyncapi/generator-react-sdk');
Expand Down

0 comments on commit fcbecd3

Please sign in to comment.