foundry_config::utils

Function find_project_root

Source
pub fn find_project_root(cwd: Option<&Path>) -> PathBuf
Expand description

Returns the root path to set for the project root.

Traverse the dir tree up and look for a foundry.toml file starting at the given path or cwd, but only until the root dir of the current repo so that:

-- foundry.toml

-- repo
  |__ .git
  |__sub
     |__ [given_path | cwd]

will still detect repo as root.

Returns repo or cwd if no foundry.toml is found in the tree.

ยงPanics

Panics if: