madge icon indicating copy to clipboard operation
madge copied to clipboard

Add support for `--include` flag

Open danburzo opened this issue 5 years ago • 3 comments

This PR adds support for an --include flag, as per #219, that filters out everything in the tree that's not matched by the regular expressions provided.

Also made the --include / --exclude flags accumulate their values in arrays, so you can provide the flags more than once in a command.

You can run madge off my branch with:

npx danburzo/madge#include ...

danburzo avatar Aug 30 '19 11:08 danburzo

Thanks for your contribution!

I could be a nice feature to add but I think your specific problem can be solved by running madge $(git diff --name-only --diff-filter=A origin/master...HEAD | grep -E '\.js$') instead which will probably be faster too since it only parses the files you give it.

pahen avatar Sep 02 '19 06:09 pahen

@pahen I mention that version in the attached issue. What I wanted to solve with --include is to limit the nodes drawn in the graph to the set of files provided as input.

To make the intention clearer, I think of --include as the counterpart of --exclude and a combination of these two options works as a lightweight CLI version of the dependencyFilter function.

danburzo avatar Sep 02 '19 06:09 danburzo

Oh, I see. It would be nice to have this functionality without having to rely on a script. Let me think about this one a little bit.

pahen avatar Sep 02 '19 07:09 pahen

Oh, I see. It would be nice to have this functionality without having to rely on a script. Let me think about this one a little bit.

Is there any update on this?

austinbiggs avatar Sep 28 '22 15:09 austinbiggs

Hi, @danburzo . Thanks for this neat PR and the issue #219.

Considering myself as a user, it's kind of confusing when we have both --include and --exclude. I've this pattern this pattern in tsconfig or its example.

Since we can pass tsconfig.json to madge already, maybe we can use the same style of include, exclude and files?

Also, the current GitHub process doesn't allow me to accept this PR due to the deleted original repo. If you are interested please create a new PR. (This PR is currently stored in branch https://github.com/pahen/madge/tree/danburzo-include) Thanks again for the contribution.

P.S. It might worth mentioning that this PR is missing according tests. It's better to add them before merging

PabloLION avatar Jan 30 '23 07:01 PabloLION

Hi @PabloLION, thanks for the ping. Honestly I need a moment to refresh my memory about this issue and PR. I had deleted my forked repo, but I can fetch the code and redo the PR if that's useful.

danburzo avatar Jan 30 '23 09:01 danburzo

@danburzo I've managed to get the code without problem. My intention was to include you as a contributor of the repo, since we just started to maintain this repo. I'm not sure if you are still interested 😂 But thanks for the contribution anyway 😃

PabloLION avatar Jan 30 '23 09:01 PabloLION

I've created a new PR, I will respond to your proposal there.

danburzo avatar Jan 30 '23 09:01 danburzo