0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-02-01 12:16:11 -05:00

fix(compile): never include the specified output executable in itself

This commit is contained in:
HasanAlrimawi 2025-01-30 17:30:10 +02:00
parent b7456fed70
commit ee0cecea29

View file

@ -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-{}",