Skip to content

Instantly share code, notes, and snippets.

@dlidstrom
Last active December 25, 2022 19:44
Show Gist options
  • Select an option

  • Save dlidstrom/a2f787cef41ea4fcb8aa74d459f49270 to your computer and use it in GitHub Desktop.

Select an option

Save dlidstrom/a2f787cef41ea4fcb8aa74d459f49270 to your computer and use it in GitHub Desktop.
Outputs all dependencies in the Angular module in a graphviz friendly format
app._invokeQueue.forEach(x => {
if (x[1] === 'constant') return;
let depsInfo = x[2];
if (typeof depsInfo[1] === 'function') {
if (!depsInfo[1] || !depsInfo[1].$inject) {
outputDependency(depsInfo[0], depsInfo[0] + "Factory");
} else {
depsInfo[1].$inject.forEach(y => outputDependency(depsInfo[0], y));
}
}
else if (_.isArray(depsInfo[1])) {
depsInfo[1].forEach(y => {
if (typeof y === 'string') {
outputDependency(depsInfo[0], y);
}
});
}
else {
outputDependency(depsInfo[0], depsInfo[0], depsInfo[1]);
}
function outputDependency(left, right, value) {
if (right.indexOf('$') === 0) return;
if (right === '_') return;
right = right.replace('.', '_');
if (value) {
console.log(left, "->", right + "Value [label = '" + JSON.stringify(value) + "']");
}
else {
console.log(left, "->", right);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment