Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function transformFile(file, callback) {
if (readFileStart(file, 150).includes('@codepen')) {
let fileSource = fs.readFileSync(file).toString();
const exampleName = path.basename(file, '.tsx');
// extract the name of the component (relies on component/examples/examplefile.tsx structure)
const transformResult = transformer(fileSource);
const dirPath = path.dirname(path.dirname(file)).replace(/((\b)src(\b))(?!.*\1)/, '$2lib/codepen$3');
if (!fs.existsSync(dirPath)) {
fs.mkdirpSync(dirPath);
}
const outPath = path.join(dirPath, exampleName + '.Codepen.txt');
logger.verbose('Writing codepen: ' + outPath);
fs.writeFileSync(outPath, transformResult);
}
callback();
}