Working package ignore
This commit is contained in:
@@ -3,13 +3,15 @@ use std::path::PathBuf;
|
||||
use std::fs;
|
||||
use std::process;
|
||||
|
||||
use crate::transpiler::MistConfig;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub class Module {
|
||||
pub name String;
|
||||
pub path PathBuf;
|
||||
pub children Vec<Box<Module>>;
|
||||
|
||||
pub constructor(mist_path PathBuf) {
|
||||
pub constructor(mist_path PathBuf, config *MistConfig) {
|
||||
self.children = Vec::new();
|
||||
self.name = mist_path.file_stem()
|
||||
.and_then(fn(s) -> s.to_str())
|
||||
@@ -25,11 +27,15 @@ pub class Module {
|
||||
self.path = pkg_gate;
|
||||
}
|
||||
|
||||
self.scan_directory(&dir);
|
||||
self.scan_directory(&dir, config);
|
||||
} else if (config.is_package(&self.path)) {
|
||||
let dir = self.path.parent().expect("Failed to get parent directory to scan").to_path_buf();
|
||||
|
||||
self.scan_directory(&dir, config);
|
||||
}
|
||||
}
|
||||
|
||||
fn scan_directory(*mut self, search_dir *Path) {
|
||||
fn scan_directory(*mut self, search_dir *Path, config *MistConfig) {
|
||||
let entries = match (fs::read_dir(search_dir)) {
|
||||
Ok[entries] => entries;
|
||||
Err[e] => {
|
||||
@@ -49,11 +55,11 @@ pub class Module {
|
||||
|
||||
let child_path = entry.path();
|
||||
|
||||
if (child_path == self.path) {
|
||||
if (child_path == self.path || child_path == config.packages[0]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
self.children.push(Module::new(child_path));
|
||||
self.children.push(Module::new(child_path, config));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,14 +79,3 @@ pub class Module {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn master_package(mist_path PathBuf) Box<Module> {
|
||||
let mut root_mod = Module::new(mist_path.clone());
|
||||
|
||||
let parent_dir = mist_path.parent()
|
||||
.expect("Failed to get parent directory of root file");
|
||||
|
||||
root_mod.scan_directory(parent_dir);
|
||||
|
||||
root_mod
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ use serde::Deserialize;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
pub struct MistConfig {
|
||||
packages Vec<PathBuf>,
|
||||
pub packages Vec<PathBuf>,
|
||||
}
|
||||
impl MistConfig {
|
||||
pub fn is_package(*self, path *Path) bool {
|
||||
@@ -46,10 +46,11 @@ pub fn transpile() PathBuf {
|
||||
*pkg = src.join(&*pkg);
|
||||
}
|
||||
|
||||
let master = modules::master_package(
|
||||
let master = modules::Module::new(
|
||||
config.packages.get(0)
|
||||
.unwrap_or_else(fn() -> panic!("Mist.toml packages must contain at least one element, eg, 'src/main.mist'"))
|
||||
.to_path_buf()
|
||||
.to_path_buf(),
|
||||
&config
|
||||
);
|
||||
|
||||
master.transpile(&out, &config);
|
||||
@@ -84,8 +85,10 @@ impl modules::Module {
|
||||
let mut output = String::new();
|
||||
|
||||
for (child : &self.children) {
|
||||
if (!config.is_package(&child.path)) {
|
||||
output.push_str(&child.transpile(&dir, config));
|
||||
}
|
||||
}
|
||||
|
||||
if (self.path.is_dir()) {
|
||||
if (output.len() == 0) {
|
||||
|
||||
Reference in New Issue
Block a user