pahen / madge

Create graphs from your CommonJS, AMD or ES6 module dependencies
MIT License
9.09k stars 317 forks source link

Idea: --only / --include flag? #219

Open danburzo opened 5 years ago

danburzo commented 5 years ago

I have just discovered Madge and it's just superb work!

It would be interesting for me, as I work on a Git branch, to understand how the files I've created relate to each other:

git diff --name-only --diff-filter=A origin/master...HEAD | grep -E '\.js$' | xargs madge

This command takes the added files as entry points, but shows their entire dependency graph. It would be great to limit it to the files I've sent as entry points.

If I understand correctly, the exclude option accepts a RegExp and I don't think I can use it.

Would an --only option make sense? It would limit the set of consider files to the original input. Or, if that's too specific, maybe an --include option (that you can use multiple time in a command), to supplement --exclude?

danburzo commented 5 years ago

Added support for the --include flag in the PR above. It's not as straightforward to use with xargs as the --only shortcut, but here's the glorious final script that does what I intended :)

FILES=$(git diff --name-only --diff-filter=AM origin/master...HEAD); \
FLAGS=$(echo $FILES | sed 's/\(.*\)/--include "\1"/g'); \
echo $FLAGS $FILES | xargs -t madge
villesau commented 2 years ago

@pahen any chance taking this in? In non-trivial apps it's almost crucial to be able to limit the scope of the graph.

PabloLION commented 1 year ago

I temporarily categorize this as visualization filtering. But for performance, maybe we don't need to generate the whole tree, which I don't think is the priority for now.