improved code quality
This commit is contained in:
@@ -32,16 +32,18 @@ pub PathBuf build(bool force) {
|
||||
|
||||
impl modules::Module {
|
||||
String transpile(self*, PathBuf* parent_dir) {
|
||||
PathBuf dir = self.output_dir(&parent_dir);
|
||||
PathBuf output_file = self.output_path(&parent_dir);
|
||||
|
||||
var _ = fs::create_dir_all(&dir);
|
||||
|
||||
String mut output = String::new();
|
||||
|
||||
for (child : &self.children) {
|
||||
output.push_str(&child.transpile(&dir));
|
||||
}
|
||||
|
||||
if (self.path.is_dir()) {
|
||||
PathBuf dir = parent_dir.join(&self.name);
|
||||
PathBuf output_file = dir.join("mod.rs");
|
||||
|
||||
String mut output = String::new();
|
||||
|
||||
for (child : &self.children) {
|
||||
output.push_str(&child.transpile(&dir));
|
||||
}
|
||||
|
||||
var res = fs::write(&output_file, output);
|
||||
|
||||
if (res.is_err()) {
|
||||
@@ -54,28 +56,7 @@ impl modules::Module {
|
||||
process::exit(1);
|
||||
}
|
||||
} else {
|
||||
if (Some("package.mist") == self.path.file_name().unwrap().to_str()) {
|
||||
PathBuf dir = parent_dir.join(&self.name);
|
||||
PathBuf output_file = dir.join("mod.rs");
|
||||
|
||||
String mut output = String::new();
|
||||
|
||||
for (child : &self.children) {
|
||||
output.push_str(&child.transpile(&dir));
|
||||
}
|
||||
|
||||
transpile_file(&self.path, &output_file, &output);
|
||||
} else {
|
||||
PathBuf output_file = parent_dir.join(&self.name).with_extension("rs");
|
||||
|
||||
String mut output = String::new();
|
||||
|
||||
for (child : &self.children) {
|
||||
output.push_str(&child.transpile(&parent_dir));
|
||||
}
|
||||
|
||||
transpile_file(&self.path, &output_file, &output);
|
||||
}
|
||||
transpile_file(&self.path, &output_file, &output);
|
||||
}
|
||||
|
||||
format!("pub mod {};\n", self.name)
|
||||
@@ -139,16 +120,3 @@ void transpile_file(PathBuf* path, PathBuf* output_file, str* mod_decl) {
|
||||
}
|
||||
}
|
||||
|
||||
bool should_skip(Path* source, Path* output) {
|
||||
var src_time = fs::metadata(source)
|
||||
.ok()
|
||||
.and_then(|var v| v.modified().ok());
|
||||
|
||||
var out_time = fs::metadata(output)
|
||||
.ok()
|
||||
.and_then(|var v| v.modified().ok());
|
||||
|
||||
out_time
|
||||
.map(|var out_time| out_time >= src_time.unwrap())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user