Skip to content

Commit 0d3717f

Browse files
authored
fix: made tool windows installations resilient against paths with whitespace (#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
1 parent 070286b commit 0d3717f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/perseus-cli/src/export.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ macro_rules! copy_directory {
8585
}
8686
}
8787
#[cfg(windows)]
88-
if std::os::unix::fs::symlink_dir($target.join($from), $target.join($to_symlink)).is_err() {
88+
if std::os::windows::fs::symlink_dir($target.join($from), $target.join($to_symlink)).is_err() {
8989
// That failed, try a usual copy
9090
if let Err(err) = fs_extra::dir::copy(
9191
$target.join($from),

packages/perseus-cli/src/install.rs

+12-4
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,15 @@ impl Tools {
141141
if let (ToolStatus::Available(wb_path), ToolStatus::Available(wo_path)) =
142142
(&wb_status, &wo_status)
143143
{
144+
#[cfg(unix)]
145+
let (wb_path, wo_path) = (wb_path.to_string(), wo_path.to_string());
146+
#[cfg(windows)]
147+
let (wb_path, wo_path) = (format!("& \'{}\'", wb_path), format!("& \'{}\'", wo_path));
144148
Ok(Tools {
145149
cargo_engine: global_opts.cargo_engine_path.clone(),
146150
cargo_browser: global_opts.cargo_browser_path.clone(),
147-
wasm_bindgen: wb_path.to_string(),
148-
wasm_opt: wo_path.to_string(),
151+
wasm_bindgen: wb_path,
152+
wasm_opt: wo_path,
149153
})
150154
} else {
151155
// We need to install some things, which may take some time
@@ -167,12 +171,16 @@ impl Tools {
167171
// If we're here, we have the paths
168172
succeed_spinner(&spinner, &spinner_msg);
169173
let paths = res.unwrap();
174+
#[cfg(unix)]
175+
let (wb_path, wo_path) = paths;
176+
#[cfg(windows)]
177+
let (wb_path, wo_path) = (format!("& \'{}\'", paths.0), format!("& \'{}\'", paths.1));
170178

171179
Ok(Tools {
172180
cargo_engine: global_opts.cargo_engine_path.clone(),
173181
cargo_browser: global_opts.cargo_browser_path.clone(),
174-
wasm_bindgen: paths.0,
175-
wasm_opt: paths.1,
182+
wasm_bindgen: wb_path,
183+
wasm_opt: wo_path,
176184
})
177185
}
178186
}

0 commit comments

Comments
 (0)