[BUG] Inconsistent output depending on the cwd where the script is run
venelinpetrov opened this issue · 4 comments
Describe the bug
I get different output from dpdm
depending on the folder where it was run. For example, if I have a structure like web/apps/<app_name>/src/index.ts
then if I run the command from /web
it says "0 circular dependencies". However, if I run it one level deeper (still targeting the same index.ts) it says "68 circular dependencies"
To Reproduce
- Try
dpdm ./a/b/c/index.ts > output1.txt
cd ./a
dpdm ./b/c/index.ts > output2.txt
- Compare output1 and output2, they are different
Expected behavior
Should produce the same result no mater cwd I guess.
Additional context
I found the issue when I fixed huge amount of circular deps, then merged and then decided to try once again after the merge. I noticed the circular depts weren't fixed, but after a while I understood that I execute the command from different folders.
I guess it is caused by the tsconfig.json
. Does your working directory contain a tsconfig.json
?
/web
contains tsconfig, indeed. Can you explain how does this affect the logic? Another way to put it, where is the proper place to run dpdm
? Thanks!
dpdm
needs tsconfig.json
to resolve path mapping, especially in mono-repo projects. If you run dpdm
in a different directory, you should pass an option --tsconfig
to the location of tsconfig.json
. For example:
dpdm -T --tsconfig ../tsconfig.json
Thank you! I think it's worth explaining this in the doc. What you described is exactly my case (i.e. monorepo)