Last active
May 28, 2018 13:22
-
-
Save imaman/f21343e3f45a09a28ae178b46b39d641 to your computer and use it in GitHub Desktop.
print hierarchy of JS classes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| node -e "var p = 'src/locators/selectors'; var kids = fs.readdirSync(p).map(x => fs.readFileSync(p + '/' + x, 'utf-8')).join('\n').split('\n').filter(x => x.match(/class .*{/)).map(x => x.replace('class ', '').replace(' {', '').replace(' extends ', ' ')).map(x => x.split(' ')).reduce((kids, p) => { kids[p[1]] = kids[p[1]] || []; kids[p[1]].push(p[0]); return kids; }, {}); function pr(indentation, k) { console.log(indentation + k); (kids[k] || []).forEach(x => pr(indentation + ' ', x)); }; pr('');" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment