Skip to content

Commit

Permalink
Fix getting the target-dir in wasm_bindgen_build
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasol committed Apr 29, 2023
1 parent 48177dc commit 0141e79
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,12 @@ pub fn wasm_bindgen_build(
};

let out_dir = out_dir.to_str().unwrap();
let has_target_dir_overwrite = extra_options.contains(&"--target-dir".to_string());
let target_directory = if has_target_dir_overwrite {
let i = extra_options
.binary_search(&"--target-dir".to_string())
.unwrap();
extra_options
.get(i + 1)
.map(Path::new)
.unwrap_or(data.target_directory())
} else {
data.target_directory()
};
let mut has_target_dir_iter = extra_options.iter();
let target_directory = has_target_dir_iter
.find(|&it| it == "--target-dir")
.and_then(|_| has_target_dir_iter.next())
.map(Path::new)
.unwrap_or(data.target_directory());

let wasm_path = target_directory
.join("wasm32-unknown-unknown")
Expand Down

0 comments on commit 0141e79

Please sign in to comment.