Open DanglSan opened 2 years ago
Thanks for raising this issue. I've added a -cf, --contractFile <filename>
option for storage diagrams in v2.1.5.
The contractFile
can just be a filename like main.sol
. Or it can be a relative filename from the working folder. eg src/contracts/main.sol
.
Thx for the quick response but are you sure, it works properly? Cause I just have checked and got an error: Failed to find contract with name "A" in filename "./same_name/main.sol"
for sol2uml storage ./same_name -c A -cf ./same_name/main.sol
. Also tried other paths (and relative to contracts folder for -cf
: sol2uml storage ./same_name -c A -cf ./main.sol
) and contracts. I got this error on Windows and WSL.
UPD: Sorry, it works properly for filename, like: sol2uml storage ./same_name -c A -cf main.sol
. But I still have problems with relative paths.
I think, I get it. There are some problems with path comparison, so sol2uml storage ./same_name -c A -cf same_name\main.sol
works fine, while all other options such as:
sol2uml storage ./same_name -c A -cf ./same_name/main.sol
sol2uml storage ./same_name -c A -cf same_name/main.sol
sol2uml storage ./same_name -c A -cf .\same_name\main.sol
return an error.
yeah, the relative paths has to be exact. Thinking about it some more, I can pass it through something like path.normalize
to pick up your examples above.
I'll reopen this issue.
I've done a change on a branch that will hopefully work for
sol2uml storage ./same_name -c A -cf .\same_name\main.sol
I don't think the forward slashes will work on Windows.
You can test by installing the branch version with
npm i -g github:@naddison36/sol2uml#contract-filename
I can include this change in the next release.
I have tested the same example and it still doesn't work. Interesting is that sol2uml storage ./same_name -c A -cf .\main.sol
now works fine. I am not sure, but it might be nessesary to add path.normalize
in this comparison?
I've added the extra path.normalize
. Can you try v2.1.6
Thx, in most situations it works great now, but when I use temporary directory like C:\Users\user\AppData\Local\Temp\.tmpYLITLN
for some reason relative_path
here has value ..\..\..\AppData\Local\Temp\.tmpYLITLN\main.sol
. And comparison of ..\..\..\AppData\Local\Temp\.tmpYLITLN\main.sol
and .tmpYLITLN\main.so
returns false, so I get Failed to find contract with name
error again.
Hmm, I'll need to look into this one. Thanks for reporting.
Running
sol2uml storage -c *same name*
on folder with files, containing contracts with the same name, will return storage diagram for contract with the smallest filename in sort order.Example:
main.sol
:Lib1.sol
:Lib2.sol
:In this example storage will be generated for
A
fromLib1.sol
. But if you renamemain.sol
inamain.sol
result will be forA
fromamain.sol
.Maybe it can be fixed by choosing both filename and contract name?