From ee0cecea29fbb63a4bbfe83560352cc549f85ee2 Mon Sep 17 00:00:00 2001 From: HasanAlrimawi Date: Thu, 30 Jan 2025 17:30:10 +0200 Subject: [PATCH] fix(compile): never include the specified output executable in itself --- cli/tools/compile.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs index 75a36e7896..bc6af3bc93 100644 --- a/cli/tools/compile.rs +++ b/cli/tools/compile.rs @@ -37,7 +37,7 @@ pub async fn compile( let binary_writer = factory.create_compile_binary_writer().await?; let http_client = factory.http_client_provider(); let entrypoint = cli_options.resolve_main_module()?; - let (module_roots, include_files) = get_module_roots_and_include_files( + let (module_roots, mut include_files) = get_module_roots_and_include_files( entrypoint, &compile_flags, cli_options.initial_cwd(), @@ -91,6 +91,15 @@ pub async fn compile( ); validate_output_path(&output_path)?; + let file_index = include_files.iter().position(|file_included| { + file_included + .path() + .ends_with(output_path.to_str().unwrap().replace(" ", "%20").as_str()) + }); + if let Some(index) = file_index { + include_files.remove(index); + } + let mut temp_filename = output_path.file_name().unwrap().to_owned(); temp_filename.push(format!( ".tmp-{}",