-
-fn project_root() -> Result<PathBuf, CliError> {
- let current_dir = std::env::current_dir()?;
- for path in current_dir.ancestors() {
- let result = std::fs::read_to_string(path.join("Cargo.toml"));
- if let Err(err) = &result {
- if err.kind() == io::ErrorKind::NotFound {
- continue;
- }
- }
-
- let content = result?;
- if content.contains("[package]\nname = \"clippy\"") {
- return Ok(path.to_path_buf());
- }
- }
-
- Err(CliError::ProjectRootNotFound)
-}