diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-09-23 17:35:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-23 17:35:48 -0400 |
commit | f6a9b49dfb57a2392ea37a64cfdee956a1c392ec (patch) | |
tree | 6e4e0586b6481d869032854acbabfa12d6edd98a /cli/tests | |
parent | 12306022da16fb5019d0a3d4f3d6e78dd7830d63 (diff) |
perf: don't re-download package tarball to global cache if local node_modules folder exists for package (#16005)
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/npm_tests.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs index 507bddb30..6f77cda84 100644 --- a/cli/tests/integration/npm_tests.rs +++ b/cli/tests/integration/npm_tests.rs @@ -578,6 +578,39 @@ fn node_modules_dir_cache() { ) .exists()); assert!(node_modules.join("@denotest/dual-cjs-esm").exists()); + + // now try deleting the folder with the package source in the npm cache dir + let package_global_cache_dir = deno_dir + .path() + .join("npm") + .join("localhost_4545") + .join("npm") + .join("registry") + .join("@denotest") + .join("dual-cjs-esm") + .join("1.0.0"); + assert!(package_global_cache_dir.exists()); + std::fs::remove_dir_all(&package_global_cache_dir).unwrap(); + + // run the output, and it shouldn't bother recreating the directory + // because it already has everything cached locally in the node_modules folder + let deno = util::deno_cmd_with_deno_dir(&deno_dir) + .current_dir(deno_dir.path()) + .arg("run") + .arg("--unstable") + .arg("--node-modules-dir") + .arg("--quiet") + .arg("-A") + .arg(util::testdata_path().join("npm/dual_cjs_esm/main.ts")) + .envs(env_vars()) + .spawn() + .unwrap(); + let output = deno.wait_with_output().unwrap(); + assert!(output.status.success()); + + // this won't exist, but actually the parent directory + // will because it still re-downloads the registry information + assert!(!package_global_cache_dir.exists()); } #[test] |