diff options
author | Rabin Gaire <rabingaire20@gmail.com> | 2022-01-11 10:09:39 +0545 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-10 23:24:39 -0500 |
commit | 605b8db8f61fc4c0c71d11cde873af18d87c49bf (patch) | |
tree | 63ecb48a02e2549aa8db941ecdd95147843a7b36 /cli/tools | |
parent | b66afa2518042cda239ef07f221722781ca660f6 (diff) |
cli(compile): fix output flag behaviour on compile command (#13299)
Diffstat (limited to 'cli/tools')
-rw-r--r-- | cli/tools/standalone.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/cli/tools/standalone.rs b/cli/tools/standalone.rs index a29b405ba..a0960d051 100644 --- a/cli/tools/standalone.rs +++ b/cli/tools/standalone.rs @@ -136,14 +136,14 @@ pub async fn write_standalone_binary( let output = match target { Some(target) => { if target.contains("windows") { - PathBuf::from(output.display().to_string() + ".exe") + output.with_extension("exe") } else { output } } None => { if cfg!(windows) && output.extension().unwrap_or_default() != "exe" { - PathBuf::from(output.display().to_string() + ".exe") + output.with_extension("exe") } else { output } @@ -175,7 +175,14 @@ pub async fn write_standalone_binary( // Remove file if it was indeed a deno compiled binary, to avoid corruption // (see https://github.com/denoland/deno/issues/10310) std::fs::remove_file(&output)?; + } else { + let output_base = &output.parent().unwrap(); + if output_base.exists() && output_base.is_file() { + bail!("Could not compile: {:?} is a file.", &output_base); + } + tokio::fs::create_dir_all(output_base).await?; } + tokio::fs::write(&output, final_bin).await?; #[cfg(unix)] { |