Skip to content

Commit

Permalink
Fix wasm build
Browse files Browse the repository at this point in the history
  • Loading branch information
jeparlefrancais committed Dec 11, 2024
1 parent 3be851f commit 34ebbce
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions site/darklua-wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ pub fn process_code(code: &str, opt_config: JsValue) -> Result<String, JsValue>
const LOCATION: &str = "file.lua";
resources.write(LOCATION, code).unwrap();

let result = darklua_core::process(
let worker_tree = darklua_core::process(
&resources,
Options::new(LOCATION).with_configuration(config),
);
)
.map_err(|err| err.to_string())?;

match result.result() {
Ok(()) => {
let lua_code = resources.get(LOCATION).unwrap();
let errors = worker_tree.collect_errors();

Ok(lua_code)
}
Err(errors) => {
let errors: Vec<_> = errors
.into_iter()
.map(|error| format!("-> {}", error))
.collect();
Err(format!("unable to process code:\n{}", errors.join("\n")).into())
}
if errors.is_empty() {
let lua_code = resources.get(LOCATION).unwrap();

Ok(lua_code)
} else {
let errors: Vec<_> = errors
.into_iter()
.map(|error| format!("-> {}", error))
.collect();
Err(format!("unable to process code:\n{}", errors.join("\n")).into())
}
}

Expand Down

0 comments on commit 34ebbce

Please sign in to comment.