Rewriting mist project structure

This commit is contained in:
2026-05-21 05:26:52 +02:00
parent 812fa5d540
commit 856c9dfdfa
4 changed files with 13 additions and 25 deletions
+4 -19
View File
@@ -6,25 +6,16 @@ use std::{
};
use mist_parser::error::ParseError;
use serde::Deserialize;
#[derive(Deserialize)]
pub struct Config {
pub src: String,
pub output: String,
}
pub fn build() -> (Config, PathBuf) {
pub fn build() -> PathBuf {
let start = Instant::now();
let root = find_project_root().unwrap_or_else(|| {
panic!("error: could not find project root (mist.json)");
});
let config = load_config(&root);
let src_dir = root.join(&config.src);
let out_dir = root.join(&config.output);
let src_dir = root.join("src");
let out_dir = root.join(".mist/src");
build_dir(&root, &src_dir, &src_dir, &out_dir);
@@ -35,7 +26,7 @@ pub fn build() -> (Config, PathBuf) {
elapsed
);
(config, root)
root
}
fn build_dir(root: &Path, base_src: &Path, current_dir: &Path, out_dir: &Path) {
@@ -187,9 +178,3 @@ pub fn find_project_root() -> Option<PathBuf> {
}
}
}
fn load_config(root: &Path) -> Config {
let content = fs::read_to_string(root.join("mist.json")).expect("failed to read mist.json");
serde_json::from_str(&content).expect("invalid mist.json format")
}