fix: ensure no node_modules directory is created when a package.json exists and no npm dependencies are used (#18134)

Closes #18133
Closes #18038
This commit is contained in:
David Sherret 2023-03-13 10:03:19 -04:00 committed by GitHub
parent 983447e860
commit 11f225ef7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 0 deletions

View file

@ -236,6 +236,10 @@ async fn sync_resolution_with_fs(
registry_url: &Url,
root_node_modules_dir_path: &Path,
) -> Result<(), AnyError> {
if snapshot.is_empty() {
return Ok(()); // don't create the directory
}
let deno_local_registry_dir = root_node_modules_dir_path.join(".deno");
fs::create_dir_all(&deno_local_registry_dir).with_context(|| {
format!("Creating '{}'", deno_local_registry_dir.display())