Updated api bootstrap
This commit is contained in:
@@ -57,7 +57,7 @@ pub bool build(Vec<String> mut args, PathBuf root) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let map = mapping.entry(mapping_path.clone()).or_insert_with(fn() {
|
let map = mapping.entry(mapping_path.clone()).or_insert_with(() => {
|
||||||
let map_str = fs::read_to_string(mapping_path).expect("Failed to read map file");
|
let map_str = fs::read_to_string(mapping_path).expect("Failed to read map file");
|
||||||
|
|
||||||
serde_json::from_str<rev_mapper::Mapping>(&map_str).expect("Failed to parse map file")
|
serde_json::from_str<rev_mapper::Mapping>(&map_str).expect("Failed to parse map file")
|
||||||
@@ -107,7 +107,7 @@ pub bool build(Vec<String> mut args, PathBuf root) {
|
|||||||
let mut stdout = std::io::stdout();
|
let mut stdout = std::io::stdout();
|
||||||
|
|
||||||
std::io::copy(&mut raw_reader, &mut stdout)
|
std::io::copy(&mut raw_reader, &mut stdout)
|
||||||
.map_err(fn(v) -> v.to_string())
|
.map_err((v) => v.to_string())
|
||||||
.expect("(Mist) Failed to copy IO");
|
.expect("(Mist) Failed to copy IO");
|
||||||
|
|
||||||
command.wait().unwrap();
|
command.wait().unwrap();
|
||||||
@@ -165,7 +165,7 @@ pub Option<String> get_line(
|
|||||||
) {
|
) {
|
||||||
let src_path = msg.file_path.clone();
|
let src_path = msg.file_path.clone();
|
||||||
|
|
||||||
let lines = files.entry(src_path.clone()).or_insert_with(fn() {
|
let lines = files.entry(src_path.clone()).or_insert_with(() => {
|
||||||
fs::read_to_string(src_path)
|
fs::read_to_string(src_path)
|
||||||
.expect("Unable to read mist file")
|
.expect("Unable to read mist file")
|
||||||
.lines()
|
.lines()
|
||||||
@@ -174,5 +174,5 @@ pub Option<String> get_line(
|
|||||||
.collect()
|
.collect()
|
||||||
});
|
});
|
||||||
|
|
||||||
lines.get(msg.line - 1).map(fn(v) -> v.trim().to_string())
|
lines.get(msg.line - 1).map((v) => v.trim().to_string())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ pub class Module {
|
|||||||
pub constructor(PathBuf mist_path, MistConfig& config) {
|
pub constructor(PathBuf mist_path, MistConfig& config) {
|
||||||
self.children = Vec::new();
|
self.children = Vec::new();
|
||||||
self.name = mist_path.file_stem()
|
self.name = mist_path.file_stem()
|
||||||
.and_then(fn(s) -> s.to_str())
|
.and_then((s) => s.to_str())
|
||||||
.expect("Failed to get module name")
|
.expect("Failed to get module name")
|
||||||
.to_string();
|
.to_string();
|
||||||
self.path = mist_path;
|
self.path = mist_path;
|
||||||
@@ -66,7 +66,7 @@ pub class Module {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub bool is_package(&self) {
|
pub bool is_package(&self) {
|
||||||
self.path.file_name().map(fn(v) -> v.to_str()).unwrap_or_default() == Some("package.mist")
|
self.path.file_name().map((v) => v.to_str()).unwrap_or_default() == Some("package.mist")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub PathBuf output_dir(&self, PathBuf& parent_dir) {
|
pub PathBuf output_dir(&self, PathBuf& parent_dir) {
|
||||||
|
|||||||
@@ -56,10 +56,10 @@ pub PathBuf transpile() {
|
|||||||
let out = root.join(".mist/src");
|
let out = root.join(".mist/src");
|
||||||
|
|
||||||
let toml_content = fs::read_to_string(&toml_path)
|
let toml_content = fs::read_to_string(&toml_path)
|
||||||
.unwrap_or_else(fn(_) -> panic!("Could not read file at {:?}", toml_path));
|
.unwrap_or_else((_) => panic!("Could not read file at {:?}", toml_path));
|
||||||
|
|
||||||
MistConfig mut config = toml::from_str(&toml_content)
|
MistConfig mut config = toml::from_str(&toml_content)
|
||||||
.unwrap_or_else(fn(_) -> panic!("Failed to parse Mist.toml from {:?}", toml_path));
|
.unwrap_or_else((_) => panic!("Failed to parse Mist.toml from {:?}", toml_path));
|
||||||
|
|
||||||
for pkg in &mut config.packages {
|
for pkg in &mut config.packages {
|
||||||
*pkg = src.join(&*pkg);
|
*pkg = src.join(&*pkg);
|
||||||
@@ -86,9 +86,9 @@ pub PathBuf transpile() {
|
|||||||
|
|
||||||
impl modules::Module {
|
impl modules::Module {
|
||||||
(bool, String) transpile(&self, PathBuf& parent_dir, MistConfig mut& config) {
|
(bool, String) transpile(&self, PathBuf& parent_dir, MistConfig mut& config) {
|
||||||
if !self.path.is_dir() && self.path.extension().and_then(fn(v) -> v.to_str()) != Some("mist") {
|
if !self.path.is_dir() && self.path.extension().and_then((v) => v.to_str()) != Some("mist") {
|
||||||
let file_name = self.path.file_name()
|
let file_name = self.path.file_name()
|
||||||
.and_then(fn(s) -> s.to_str())
|
.and_then((s) => s.to_str())
|
||||||
.expect("Failed to get file name");
|
.expect("Failed to get file name");
|
||||||
|
|
||||||
fs::copy(&self.path, parent_dir.join(&file_name)).expect("Failed to copy SideFile");
|
fs::copy(&self.path, parent_dir.join(&file_name)).expect("Failed to copy SideFile");
|
||||||
@@ -200,8 +200,8 @@ pub Result<(PathBuf, mist_codegen::RustCodegen, String), TranspileError<'a>>
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
if let Some((_, name)) = &curr_mod_decl {
|
if let Some((_, name)) = &curr_mod_decl {
|
||||||
if output_file.file_name().map(fn(v) -> v.to_str()).unwrap_or_default() != Some("mod.rs") {
|
if output_file.file_name().map((v) => v.to_str()).unwrap_or_default() != Some("mod.rs") {
|
||||||
if let Some(ext) = output_file.extension().map(fn(e) -> e.to_owned()) {
|
if let Some(ext) = output_file.extension().map((e) => e.to_owned()) {
|
||||||
let mut new_name = std::ffi::OsString::from(&name.0);
|
let mut new_name = std::ffi::OsString::from(&name.0);
|
||||||
|
|
||||||
new_name.push(".");
|
new_name.push(".");
|
||||||
|
|||||||
Reference in New Issue
Block a user