Open
Description
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: