Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion src/discover_projects/detect_cleanable_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub fn detect_cleanable_project(path: &Path) -> Option<Project> {
}

// Create an empty project so we can add cleanable directories to it
let mut project = Project::new(path.clone());
let mut project = Project::new(path);

// This flag will keep track of whether we've found a project
let mut is_project = false;
Expand Down Expand Up @@ -60,6 +60,17 @@ pub fn detect_cleanable_project(path: &Path) -> Option<Project> {
project.add_cleanable_dir_if_exists("build");
}

// Python projects
if exists_in_path(path, "__pycache__") {
is_project = true;
project.add_cleanable_dir_if_exists("__pycache__");
}
if exists_in_path(path, "site-packages") {
is_project = true;
project.add_cleanable_dir_if_exists("site-packages");
}


if is_project {
return Some(project);
} else {
Expand Down Expand Up @@ -161,6 +172,21 @@ mod test {
);
}

#[test]
fn python() {
test_project!(
files: ["some_file"],
dirs: ["site-packages", "other"],
cleanable: ["site-packages"]
);

test_project!(
files: ["some_file"],
dirs: ["__pycache__", "other"],
cleanable: ["__pycache__"]
);
}

#[test]
fn empty_dir() {
test_utils::with_temp_dir(|dir| {
Expand Down