Forráskód Böngészése

Expand on it so if it's nested crates

For example:

dev/
    rust/
         major_project/
                       crate1/
                              src/
                              target/
                       crate2/
                              src/
                              target/

Basically, this will allow major_project/crate1 and crate2 to get
cleaned (So long as the root project isn't a project that could be
cleaned as well)
Apollo 3 hete
szülő
commit
40dba3588b
1 módosított fájl, 14 hozzáadás és 0 törlés
  1. 14 0
      src/main.rs

+ 14 - 0
src/main.rs

@@ -30,6 +30,20 @@ fn clean_in_dir(path: PathBuf) -> Result<u64, std::io::Error> {
                 println!(" => {}", p.display());
                 execute_clean(p)?;
                 cleaned += 1;
+            } else {
+                // Maybe nested?
+                for ent in fs::read_dir(p)? {
+                    let ent = ent?;
+                    let p2 = ent.path();
+                    if p2.is_dir() {
+                        let needed = find_target_dir(p2.clone())?;
+                        if needed {
+                            println!(" => {}", p2.display());
+                            execute_clean(p2)?;
+                            cleaned += 1;
+                        }
+                    }
+                }
             }
         }
     }