diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-12-06 16:25:24 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-06 16:25:24 -0500 |
commit | 7fdc3c8f1fc27be2ca7d4ff62b9fd8ecb3d24e61 (patch) | |
tree | e0de42001e5185091e00dd0232d82f98621edd14 /cli/tools/compile.rs | |
parent | 07f78912d629eb788cd9feca344e6b4720a3bef3 (diff) |
fix(compile/npm): ignore symlinks to non-existent paths in node_modules directory (#21479)
Part of https://github.com/denoland/deno/issues/21476
Diffstat (limited to 'cli/tools/compile.rs')
-rw-r--r-- | cli/tools/compile.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs index ebba884cd..b36ee94bd 100644 --- a/cli/tools/compile.rs +++ b/cli/tools/compile.rs @@ -71,8 +71,9 @@ pub async fn compile( ); validate_output_path(&output_path)?; - let mut file = std::fs::File::create(&output_path)?; - binary_writer + let mut file = std::fs::File::create(&output_path) + .with_context(|| format!("Opening file '{}'", output_path.display()))?; + let write_result = binary_writer .write_bin( &mut file, eszip, @@ -81,8 +82,13 @@ pub async fn compile( cli_options, ) .await - .with_context(|| format!("Writing {}", output_path.display()))?; + .with_context(|| format!("Writing {}", output_path.display())); drop(file); + if let Err(err) = write_result { + // errored, so attempt to remove the output path + let _ = std::fs::remove_file(output_path); + return Err(err); + } // set it as executable #[cfg(unix)] |