Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = async (html, config) => {
const options = config.inlineCSS
if (options && options.enabled) {
if (options.styleToAttribute) {
juice.styleToAttribute = options.styleToAttribute || juice.styleToAttribute
}
if (typeof options.applySizeAttribute === 'object') {
juice.widthElements = typeof options.applySizeAttribute.width === 'object' ? Object.values(options.applySizeAttribute.width) : juice.widthElements
juice.heightElements = typeof options.applySizeAttribute.height === 'object' ? Object.values(options.applySizeAttribute.height) : juice.heightElements
}
if (options.excludedProperties) {
juice.excludedProperties = typeof options.excludedProperties === 'object' ? Object.values(options.excludedProperties) : juice.excludedProperties
}
if (options.codeBlocks) {
Object.entries(options.codeBlocks).forEach(
([k, v]) => juice.codeBlocks[k] = v // eslint-disable-line
)
}
files.map((file) => {
let html = fs.readFileSync(file, 'utf8');
if (inlineOpts.enabled) {
if (inlineOpts.styleToAttribute) {
juice.styleToAttribute = inlineOpts.styleToAttribute || juice.styleToAttribute;
}
if (inlineOpts.applySizeAttribute) {
juice.widthElements = inlineOpts.applySizeAttribute.width || juice.widthElements;
juice.heightElements = inlineOpts.applySizeAttribute.height || juice.heightElements;
}
if (inlineOpts.excludedProperties) {
juice.excludedProperties = inlineOpts.excludedProperties || juice.excludedProperties;
}
if (inlineOpts.codeBlocks) {
Object.entries(inlineOpts.codeBlocks).forEach(
([k, v]) => juice.codeBlocks[k] = v
);
}