Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 該当ディレクトリ以下で find . | grep -E "jsx$" | xargs -I {} node searchSameMethod.js {}
- const fs = require('fs');
- const filepath = process.argv[2]
- const main = async (filepath) => {
- const file = await readutf8(filepath);
- const pa = file.match(/^ ([a-zA-z]*)\(/gm);
- const pb = file.match(/^ ([a-zA-z]*) =/gm);
- let matched;
- if (pa && pb) {
- matched = pa.concat(pb);
- } else if (pb === null) {
- matched = pa;
- } else {
- matched = pb;
- }
- if (!matched) {
- return;
- }
- matched.forEach((e, i) => {
- const filterd = matched.filter((b, idx) => idx !== i);
- filterd.forEach(element => {
- if (element === e) console.log('element', filepath, element);
- });
- });
- }
- main(filepath)
- async function readutf8(filepath) {
- return new Promise((resolve, reject) => {
- return fs.readFile(filepath, { encoding: 'utf8' }, (err, data) => {
- return err ? reject(err) : resolve(data);
- });
- });
- }
- ```
Add Comment
Please, Sign In to add comment