diff --git a/docker-compose.yml b/docker-compose.yml index 9bb1ee6..36d7388 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -17,6 +17,8 @@ services: - /usr/src/app/node_modules links: - maildev + depends_on: + - maildev environment: - MAILDEV_SMTP_PORT=25 - MAILDEV_SMTP_ENDPOINT=maildev diff --git a/src/helpers/buildMjmlTemplate.ts b/src/helpers/buildMjmlTemplate.ts index 6c5ce3d..26718f0 100644 --- a/src/helpers/buildMjmlTemplate.ts +++ b/src/helpers/buildMjmlTemplate.ts @@ -26,13 +26,14 @@ export const buildMjmlTemplate = async (options: IPluginOptions, templateName: s throw new Error(`[nodemailer-mjml] - Could not read mjml template at path: ${mjmlTemplatePath}`); }); - const shouldRunMustacheCompiler = !!templateData && Object.keys(templateData).length > 0; + const shouldRunMustacheCompiler = !!templateData && Object.keys(templateData ?? {}).length > 0; const mustacheRenderedTemplate = shouldRunMustacheCompiler ? render(rawMjmlTemplate, templateData) : rawMjmlTemplate; const mjmlOutput = mjml2html(mustacheRenderedTemplate, { filePath: mjmlTemplatePath, ...renderOptions.mjmlOptions }); + checkMjmlError(mjmlOutput); const finalHtmlOutput = renderOptions.minifyHtmlOutput ? minify(mjmlOutput.html, renderOptions.htmlMinifierOptions) : mjmlOutput.html;