Skip to content

Commit

Permalink
Exclude veryl sources in inner projects
Browse files Browse the repository at this point in the history
  • Loading branch information
dalance committed Jun 7, 2024
1 parent 76f3694 commit f76b9f4
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions crates/metadata/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,34 @@ pub fn gather_files_with_extension<T: AsRef<Path>>(
ext: &str,
symlink: bool,
) -> Result<Vec<PathBuf>, MetadataError> {
let mut inner_prj = Vec::new();
for entry in WalkDir::new(base_dir.as_ref()).follow_links(symlink) {
let entry = entry?;
if entry.file_type().is_file() {
if let Some(x) = entry.path().file_name() {
if x == "Veryl.toml" {
let prj_dir = entry.path().parent().unwrap();
if prj_dir != base_dir.as_ref() {
debug!("Found inner project ({})", prj_dir.to_string_lossy());
inner_prj.push(prj_dir.to_path_buf());
}
}
}
}
}

let mut ret = Vec::new();
for entry in WalkDir::new(base_dir).follow_links(symlink) {
for entry in WalkDir::new(base_dir.as_ref()).follow_links(symlink) {
let entry = entry?;
if entry.file_type().is_file() {
if let Some(x) = entry.path().extension() {
if x == ext {
debug!("Found file ({})", entry.path().to_string_lossy());
ret.push(entry.path().to_path_buf());
let is_inner = inner_prj.iter().any(|x| entry.path().starts_with(x));

if !is_inner {
debug!("Found file ({})", entry.path().to_string_lossy());
ret.push(entry.path().to_path_buf());
}
}
}
}
Expand Down

0 comments on commit f76b9f4

Please sign in to comment.