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
Fixes #1278
  • Loading branch information
tomasol committed May 30, 2023
1 parent 3073db8 commit 75e61d4
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/bindgen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,14 @@ 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)

let target_directory = {
let mut has_target_dir_iter = extra_options.iter();
has_target_dir_iter
.find(|&it| it == "--target-dir")
.and_then(|_| has_target_dir_iter.next())
.map(Path::new)
.unwrap_or(data.target_directory())
} else {
data.target_directory()
};

let wasm_path = target_directory
Expand Down

0 comments on commit 75e61d4

Please sign in to comment.