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
34
35
use include_dir::{include_dir, Dir};
use indoc::indoc;
use std::{io::Write, path::PathBuf};

static SCSS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/scss");

/// Path must point to a folder which can be deleted and recreated freely!
pub fn generate(path: PathBuf) {
    if path.exists() {
        std::fs::remove_dir_all(&path).unwrap();
    }
    std::fs::create_dir_all(&path).unwrap();

    SCSS_DIR.extract(&path).unwrap();

    let mut file = std::fs::OpenOptions::new()
        .create(true)
        .write(true)
        .append(false)
        .truncate(true)
        .open(path.join("leptonic-themes.scss"))
        .unwrap();

    file.write_all(
        indoc!(
            r#"
            @import "./themes/builder";
            @import "./themes/light";
            @import "./themes/dark";
            "#
        )
        .as_bytes(),
    )
    .unwrap();
}