Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

traverse file tree to discover config file #538

Open
0xalpharush opened this issue Jan 16, 2024 · 0 comments
Open

traverse file tree to discover config file #538

0xalpharush opened this issue Jan 16, 2024 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed high-priority

Comments

@0xalpharush
Copy link
Member

0xalpharush commented Jan 16, 2024

          On a second look, I think target is always a directory here, so scratch that last part of my comment.

Unrelated to this PR, but I think the check here may be a bit off, wouldn't it make more sense to look for the foundry/etc project in the path of the file rather than in cwd? e.g. if the file is /a/b/c/d/contracts/foo.sol, I'd check to see if any of [/a/b/c/d/contracts, /a/b/c/d, /a/b/c, /a/b, /a, /] is a project. Most users are probably going to be running the tool with cwd=the project folder, so it may work as-is now, but it doesn't feel completely correct.

Originally posted by @elopez in #515 (comment)

Something like this:

                config_root = self._working_dir
                while os.path.realpath(config_root) != os.path.realpath("/"):
                    platform_wd = next(
                        (
                            p(target)
                            for p in get_platforms()
                            if p.is_supported(str(config_root), **kwargs)
                        ),
                        None,
                    )
                    if platform_wd:
                        break
                    config_root = os.path.dirname(config_root)

We should search for the config file before falling back to best-effort, standard json compilation here:

elif os.path.isdir(target):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed high-priority
Projects
None yet
Development

No branches or pull requests

1 participant