Created
June 27, 2019 16:59
-
-
Save leostaples/01622f7c77f9a73e2275e67583f2985f to your computer and use it in GitHub Desktop.
Script to find recursively search lx-page dependencies to find which ones reference bbc-morph-grandstand
This file contains 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
function parseDependencies(module) { | |
console.log("parseDependencies", module); | |
if (!parseDependencies.results) parseDependencies.results = []; | |
if (!parseDependencies.seenBefore) parseDependencies.seenBefore = {}; | |
if (!(module in parseDependencies.seenBefore)) { | |
parseDependencies.seenBefore[module] = true; | |
var package_json = require('/Users/stapll/code/morph-modules/' + module + '/package.json'); | |
var dependencies = package_json.dependencies; | |
if (dependencies.hasOwnProperty('bbc-morph-grandstand')) { | |
parseDependencies.results.push(module); | |
} | |
for (var module in dependencies) { | |
var regex = /^bbc-morph-(.*)/; | |
var found = module.match(regex); | |
if (found && found[1] !== 'grandstand') { | |
parseDependencies(found[1]) | |
} | |
} | |
} | |
return parseDependencies.results; | |
} | |
var results = parseDependencies('lx-page'); | |
console.log("Results: ", results); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment