1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use super::*;

/// Build the Rust WASM app and all of its assets.
#[derive(Clone, Debug, Parser)]
#[clap(name = "clean")]
pub struct Clean {}

impl Clean {
    pub fn clean(self) -> Result<()> {
        let crate_config = crate::CrateConfig::new()?;

        let output = Command::new("cargo")
            .arg("clean")
            .stdout(Stdio::piped())
            .stderr(Stdio::piped())
            .output()?;

        if !output.status.success() {
            return custom_error!("Cargo clean failed.");
        }

        let out_dir = crate_config
            .dioxus_config
            .application
            .out_dir
            .unwrap_or_else(|| PathBuf::from("dist"));
        if crate_config.crate_dir.join(&out_dir).is_dir() {
            remove_dir_all(crate_config.crate_dir.join(&out_dir))?;
        }

        Ok(())
    }
}