Skip to content

Commit

Permalink
Refactor compile_vrl_wasm.rs to utilize for-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpv committed Mar 9, 2023
1 parent 8a18a65 commit 7ec1898
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions vdev/src/commands/compile_vrl_wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,15 @@ pub struct Cli {}

impl Cli {
pub fn exec(self) -> Result<()> {
let crates = vec!["compiler", "core", "diagnostic", "parser"];
let vrl_path = Path::new(app::path()).join("lib").join("vrl");
let args = vec!["build", "--release", "--target", "wasm32-unknown-unknown"];
println!("Compiling lib/vrl/compiler to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join("compiler"))?;
app::exec("cargo", &args, false)?;

println!("Compiling lib/vrl/core to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join("core"))?;
app::exec("cargo", &args, false)?;

println!("Compiling lib/vrl/diagnostic to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join("diagnostic"))?;
app::exec("cargo", &args, false)?;

println!("Compiling lib/vrl/parser to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join("parser"))?;
app::exec("cargo", &args, false)?;
for crate_name in crates {
println!("Compiling lib/vrl/{crate_name} to wasm32-unknown-unknown");
std::env::set_current_dir(vrl_path.join(crate_name))?;
app::exec("cargo", &args, false)?;
}
Ok(())
}
}

0 comments on commit 7ec1898

Please sign in to comment.