Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
inputs.forEach(i => {
try {
let compiled
switch (inputOpt) {
case 'm': // eslint-disable-line no-case-declarations
compiled = { html: migrate(i.mjml, { beautify: true }) }
break
case 'v': // eslint-disable-line no-case-declarations
const mjmlJson = MJMLParser(i.mjml, { components })
compiled = {
errors: validate(mjmlJson, { components, initializeType }),
}
break
default:
compiled = mjml2html(i.mjml, { ...config, filePath: filePath || i.file })
}
convertedStream.push({ ...i, compiled })
} catch (e) {
EXIT_CODE = 2
failedStream.push({ file: i.file, error: e })
}
})
validate () {
if (this.options.level == "skip") {
return;
}
this.errors = MJMLValidator(this.content)
if (this.options.level == "strict" && this.errors.length > 0) {
throw new MJMLValidationError(this.errors)
}
}
title: '',
forceOWADesktop: get(mjml, 'attributes.owa', 'mobile') === 'desktop',
lang: get(mjml, 'attributes.lang'),
}
const validatorOptions = {
components,
initializeType,
}
switch (validationLevel) {
case 'skip':
break
case 'strict':
errors = MJMLValidator(mjml, validatorOptions)
if (errors.length > 0) {
throw new ValidationError(
`ValidationError: \n ${errors
.map(e => e.formattedMessage)
.join('\n')}`,
errors,
)
}
break
case 'soft':
default:
errors = MJMLValidator(mjml, validatorOptions)
break
}
case 'strict':
errors = MJMLValidator(mjml, validatorOptions)
if (errors.length > 0) {
throw new ValidationError(
`ValidationError: \n ${errors
.map(e => e.formattedMessage)
.join('\n')}`,
errors,
)
}
break
case 'soft':
default:
errors = MJMLValidator(mjml, validatorOptions)
break
}
const mjBody = find(mjml.children, { tagName: 'mj-body' })
const mjHead = find(mjml.children, { tagName: 'mj-head' })
const processing = (node, context, parseMJML = identity) => {
if (!node) {
return
}
const component = initComponent({
name: node.tagName,
initialDatas: {
...parseMJML(node),
context,