From cf2f93d480559a4d1c570438878848f567906143 Mon Sep 17 00:00:00 2001 From: Erica Marigold Date: Thu, 23 Nov 2023 11:17:10 +0530 Subject: [PATCH] fix: conditionally compile fs writing system for windows --- src/cli/build.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/cli/build.rs b/src/cli/build.rs index b158c69..ed5a050 100644 --- a/src/cli/build.rs +++ b/src/cli/build.rs @@ -44,18 +44,18 @@ pub async fn build_standalone + Into>( patched_bin.append(&mut signature.clone()); // Write the compiled binary to file - if cfg!(unix) { - OpenOptions::new() - .write(true) - .create(true) - .mode(0o770) - .open(output_path) - .await? - .write_all(&patched_bin) - .await?; - } else if cfg!(windows) { - fs::write(output_path, &patched_bin).await?; - } + #[cfg(not(target_os = "windows"))] + OpenOptions::new() + .write(true) + .create(true) + .mode(0o770) + .open(&output_path) + .await? + .write_all(&patched_bin) + .await?; + + #[cfg(target_os = "windows")] + fs::write(&output_path, &patched_bin).await?; Ok(ExitCode::SUCCESS) }