Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fileMappings[srcFile].forEach((targetFile) => {
const filePath = path.resolve(basePath, `${srcFile}${type ? `_${type}` : ''}.svg`);
if (!fs.existsSync(filePath)) return;
fs.readFile(filePath)
.then((src) => svg2png(src, { width: targetFile.width, height: targetFile.height }))
.then(buffer => {
mkdirp.sync(path.dirname(path.resolve(typeTargetPath, `${targetFile.name}.png`)));
return fs.writeFile(path.resolve(typeTargetPath, `${targetFile.name}.png`), buffer);
})
.then(doIcons.bind(this, type, typeTargetPath))
.catch(e => console.error(e));
});
});