Skip to main content

devcap_core/
discovery.rs

1use std::path::{Path, PathBuf};
2use walkdir::WalkDir;
3
4const SKIP_DIRS: &[&str] = &[
5    "node_modules",
6    "vendor",
7    "target",
8    ".bundle",
9    "Pods",
10    ".build",
11    "dist",
12    "build",
13    ".next",
14    ".cache",
15];
16
17pub fn find_repos(root: &Path) -> Vec<PathBuf> {
18    WalkDir::new(root)
19        .into_iter()
20        .filter_entry(|entry| {
21            if !entry.file_type().is_dir() {
22                return true;
23            }
24            let name = entry.file_name().to_string_lossy();
25            !SKIP_DIRS.contains(&name.as_ref())
26        })
27        .filter_map(Result::ok)
28        .filter(|entry| entry.file_type().is_dir() && entry.file_name() == ".git")
29        .filter_map(|entry| entry.path().parent().map(Path::to_path_buf))
30        .collect()
31}