Skip to content

Commit

Permalink
fix: made tool windows installations resilient against paths with whi…
Browse files Browse the repository at this point in the history
…tespace (#228)

* fix: fixed symlink code for windows

* fix: fixed #227 with change to tool path

Changes tool paths to use "& '\{tool_path}'\" so that they work on windows powershell when there are whitespaces in the directory path
  • Loading branch information
IsaacTay authored Nov 24, 2022
1 parent 070286b commit 0d3717f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/perseus-cli/src/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ macro_rules! copy_directory {
}
}
#[cfg(windows)]
if std::os::unix::fs::symlink_dir($target.join($from), $target.join($to_symlink)).is_err() {
if std::os::windows::fs::symlink_dir($target.join($from), $target.join($to_symlink)).is_err() {
// That failed, try a usual copy
if let Err(err) = fs_extra::dir::copy(
$target.join($from),
Expand Down
16 changes: 12 additions & 4 deletions packages/perseus-cli/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,15 @@ impl Tools {
if let (ToolStatus::Available(wb_path), ToolStatus::Available(wo_path)) =
(&wb_status, &wo_status)
{
#[cfg(unix)]
let (wb_path, wo_path) = (wb_path.to_string(), wo_path.to_string());
#[cfg(windows)]
let (wb_path, wo_path) = (format!("& \'{}\'", wb_path), format!("& \'{}\'", wo_path));
Ok(Tools {
cargo_engine: global_opts.cargo_engine_path.clone(),
cargo_browser: global_opts.cargo_browser_path.clone(),
wasm_bindgen: wb_path.to_string(),
wasm_opt: wo_path.to_string(),
wasm_bindgen: wb_path,
wasm_opt: wo_path,
})
} else {
// We need to install some things, which may take some time
Expand All @@ -167,12 +171,16 @@ impl Tools {
// If we're here, we have the paths
succeed_spinner(&spinner, &spinner_msg);
let paths = res.unwrap();
#[cfg(unix)]
let (wb_path, wo_path) = paths;
#[cfg(windows)]
let (wb_path, wo_path) = (format!("& \'{}\'", paths.0), format!("& \'{}\'", paths.1));

Ok(Tools {
cargo_engine: global_opts.cargo_engine_path.clone(),
cargo_browser: global_opts.cargo_browser_path.clone(),
wasm_bindgen: paths.0,
wasm_opt: paths.1,
wasm_bindgen: wb_path,
wasm_opt: wo_path,
})
}
}
Expand Down

0 comments on commit 0d3717f

Please sign in to comment.