Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await Promise.all(outputDirs.map((dir) => rimraf(dir)));
if (shouldGenerateReactComponent) {
await mkdirp(OUTPUT_DIR);
}
console.log(chalk.green(`[Generate SVG Component] Icon Amount: ${svgFileNames.length}`));
const componentNames = [];
const metaData = {};
const mirrorMetaData = {};
for (const svgPath of svgFilePaths) {
const svgCode = fs.readFileSync(svgPath);
const svgName = `${getComponentName({ filePath: svgPath })}`;
componentNames.push(svgName);
const kebabcaseName = kebabcase(svgName);
metaData[kebabcaseName] = svgName;
mirrorMetaData[svgName] = kebabcaseName;
if (shouldGenerateReactComponent) {
const componentCode = await svgr(svgCode, svgrConfig, { filePath: svgPath });
fs.writeFileSync(path.resolve(OUTPUT_DIR, `${svgName}.tsx`), componentCode);
}
}
if (shouldGenerateReactComponent) {
console.log(chalk.green(`[Generate SVG Component] Icon Components Generated!`));
}