Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async optimizeFile(path) {
try {
const dataUri = await DataURI(path);
const originalBuffer = await fs.readFile(path);
const optimizedBuffer = await imagemin.buffer(originalBuffer, { plugins: imageMinPlugins });
await fs.writeFile(path, optimizedBuffer);
return {
dataUri: dataUri,
originalSize: originalBuffer.length,
optimizedSize: optimizedBuffer.length
}
} catch (error) {
return { status: false, originalSize: null, optimizedSize: null }
console.error('Error: ', error);
}
}
this.mainRenderer.image = function(href, title, text) {
if (!href.match(/^https?:\/\//)) {
href = path.resolve(self.wikiPath, href)
return util.format('<img src="%s">', datauri(href))
} else {
return util.format('<img src="%s">', href)
}
}
return this
this.mainRenderer.image = function (href, title, text) {
if (!href.match(/^https?:\/\//)) {
href = path.resolve(self.wikiPath, href);
return util.format('<img src="%s">', datauri(href));
} else {
return util.format('<img src="%s">', href);
}
};
return this;
getLimedocsGeneratedImgData() {
return datauri(path.resolve(__dirname, '../assets/images/Limedocs-generated.png'))
}
'inline-image($path)': function inlineImage(filepath) {
const imagePath = getFilePath(filepath);
if (imagePath) {
return new types.String('url(\'' + datauri(imagePath) + '\')');
}
return null;
}
};
value: function getLimedocsGeneratedImgData() {
return datauri(path.resolve(__dirname, '../assets/images/Limedocs-generated.png'));
}
}, {