Skip to content

Instantly share code, notes, and snippets.

@hawx1993
Created October 18, 2022 05:48
Show Gist options
  • Select an option

  • Save hawx1993/2d233f87864638849e2787dd7c7fa352 to your computer and use it in GitHub Desktop.

Select an option

Save hawx1993/2d233f87864638849e2787dd7c7fa352 to your computer and use it in GitHub Desktop.
const glob = require('glob');
const fs = require('fs-extra');
const HeavenIcons = require('@perfma/icons');
const filePath = './src/pages/License/components/StepArea.tsx'; // process.argv[2];
// Usage
// node index.js ../foo/\*.js
// console.log('HeavenIcons', HeavenIcons);
glob(filePath, (err, files) => {
if (err) throw err;
files.forEach((file) => {
fs.readFile(file, 'utf8').then((code) => {
const re = /<IconFont type=".*?" \/>/g;
const matchResults = code.match(re);
console.log('matchResults', matchResults);
if (!matchResults) return;
const methodNames = matchResults.map((result) =>
// result.replace('lodash.', '').replace('(', '')
);
// const filteredNames = Array.from(new Set(methodNames));
// let modCode = code.replace(
// `import lodash from 'lodash'`,
// `import { ${filteredNames.join(', ')} } from 'lodash'`
// );
// matchResults.forEach((result, i) => {
// // eslint-disable-next-line
// const re = result.replace('.', '\\.').replace('(', '\\(');
// modCode = modCode.replace(new RegExp(re, 'g'), methodNames[i] + '(');
// });
// fs.writeFile(file, modCode, 'utf8');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment