From f154c169f7dd39cc3fb8c18849234715942515b8 Mon Sep 17 00:00:00 2001 From: Zeb Piasecki Date: Mon, 19 Sep 2022 07:48:53 -0700 Subject: [PATCH] fix: worker-build not working on windows --- worker-build/src/install.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/worker-build/src/install.rs b/worker-build/src/install.rs index f4bb2aef..50448968 100644 --- a/worker-build/src/install.rs +++ b/worker-build/src/install.rs @@ -20,7 +20,9 @@ pub fn is_installed(name: &str) -> Result> { let file_type = entry.file_type()?; let is_file_or_symlink = file_type.is_symlink() || file_type.is_file(); - if is_file_or_symlink && entry.file_name() == name { + if is_file_or_symlink + && entry.file_name() == format!("{name}{BINARY_EXTENSION}").as_str() + { return Ok(Some(entry.path())); } } @@ -50,6 +52,7 @@ pub fn ensure_wasm_pack() -> Result<()> { } const ESBUILD_VERSION: &str = "0.14.47"; +const BINARY_EXTENSION: &str = if cfg!(windows) { ".exe" } else { "" }; pub fn ensure_esbuild() -> Result { // If we already have it we can skip the download. @@ -57,7 +60,7 @@ pub fn ensure_esbuild() -> Result { return Ok(path); }; - let esbuild_binary = format!("esbuild-{}", platform()); + let esbuild_binary = format!("esbuild-{}{BINARY_EXTENSION}", platform()); let esbuild_bin_path = dirs_next::cache_dir() .unwrap_or_else(std::env::temp_dir) .join(esbuild_binary); @@ -101,7 +104,7 @@ fn download_esbuild(writer: &mut impl Write) -> Result<()> { if path .file_name() - .map(|name| name == "esbuild") + .map(|name| name == format!("esbuild{BINARY_EXTENSION}").as_str()) .unwrap_or(false) { std::io::copy(&mut entry, writer)?;