From 74584eef04a0a395d903ec9fcb8d91caf305be41 Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sun, 7 Mar 2021 18:50:01 +0530 Subject: fix(cli/compile): do not append .exe depending on target (#9668) --- cli/tools/standalone.rs | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'cli/tools') diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index 884d2a31d..062b80732 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -129,14 +129,25 @@ pub fn create_standalone_binary( /// is not already standalone binary it will return error instead. pub async fn write_standalone_binary( output: PathBuf, + target: Option, final_bin: Vec, ) -> Result<(), AnyError> { - let output = - if cfg!(windows) && output.extension().unwrap_or_default() != "exe" { - PathBuf::from(output.display().to_string() + ".exe") - } else { - output - }; + let output = match target { + Some(target) => { + if target.contains("windows") { + PathBuf::from(output.display().to_string() + ".exe") + } else { + output + } + } + None => { + if cfg!(windows) && output.extension().unwrap_or_default() != "exe" { + PathBuf::from(output.display().to_string() + ".exe") + } else { + output + } + } + }; if output.exists() { // If the output is a directory, throw error -- cgit v1.2.3