child condition for packages
This commit is contained in:
@@ -84,7 +84,7 @@ pub fn transpile() PathBuf {
|
||||
}
|
||||
|
||||
impl modules::Module {
|
||||
fn transpile(*self, parent_dir *PathBuf, config *mut MistConfig) String {
|
||||
fn transpile(*self, parent_dir *PathBuf, config *mut MistConfig) [bool, String] {
|
||||
if !self.path.is_dir() && self.path.extension().and_then(fn(v) -> v.to_str()) != Some("mist") {
|
||||
let file_name = self.path.file_name()
|
||||
.and_then(fn(s) -> s.to_str())
|
||||
@@ -92,7 +92,7 @@ impl modules::Module {
|
||||
|
||||
fs::copy(&self.path, parent_dir.join(&file_name)).expect("Failed to copy SideFile");
|
||||
|
||||
return String::new();
|
||||
return (true, String::new());
|
||||
}
|
||||
|
||||
let dir = self.output_dir(parent_dir);
|
||||
@@ -101,9 +101,16 @@ impl modules::Module {
|
||||
|
||||
let mut output = String::new();
|
||||
|
||||
let mut child_changed = false;
|
||||
|
||||
for child in &self.children {
|
||||
if !config.should_ignore(&child.path) {
|
||||
output.push_str(&child.transpile(&dir, config));
|
||||
let out = child.transpile(&dir, config);
|
||||
if out.0 {
|
||||
child_changed = true;
|
||||
}
|
||||
|
||||
output.push_str(&out.1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,15 +120,15 @@ impl modules::Module {
|
||||
output.push_str(&config.main_mods)
|
||||
}
|
||||
|
||||
self.write_transpile(output, parent_dir)
|
||||
self.write_transpile(output, parent_dir, child_changed)
|
||||
}
|
||||
|
||||
fn write_transpile(*self, output String, parent_dir *PathBuf) String {
|
||||
fn write_transpile(*self, output String, parent_dir *PathBuf, child_changed bool) [bool, String] {
|
||||
if self.path.is_dir() {
|
||||
let output_file = self.output_path(parent_dir, &None);
|
||||
|
||||
if output.len() == 0 {
|
||||
return String::new();
|
||||
return (true, String::new());
|
||||
}
|
||||
|
||||
let res = fs::write(&output_file, output);
|
||||
@@ -136,7 +143,7 @@ impl modules::Module {
|
||||
process::exit(1);
|
||||
}
|
||||
|
||||
format!("pub mod {};\n", self.name)
|
||||
(false, format!("pub mod {};\n", self.name))
|
||||
} else {
|
||||
let source = match fs::read_to_string(&self.path) {
|
||||
Ok[s] => s;
|
||||
@@ -151,15 +158,17 @@ impl modules::Module {
|
||||
|
||||
let output_file = self.output_path(parent_dir, &curr_mod_decl);
|
||||
|
||||
if is_source_newer(&self.path, &output_file).expect("Failed to cache") {
|
||||
let should_change = is_source_newer(&self.path, &output_file).expect("Failed to cache");
|
||||
|
||||
if should_change || child_changed {
|
||||
transpile_file(&self.path, &source, output_file, &output, &curr_mod_decl);
|
||||
}
|
||||
|
||||
if let Some[[vis, name]] = &curr_mod_decl {
|
||||
(should_change, if let Some[[vis, name]] = &curr_mod_decl {
|
||||
format!("{}mod {};\n", vis.get_rust(), name.get_rust())
|
||||
} else {
|
||||
String::new()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user