Skip to content

traverse file tree to discover config file #538

Open
@0xalpharush

Description

@0xalpharush
          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):

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions