diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-09-03 15:31:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-03 15:31:01 +0200 |
commit | 223403e899c934e23ea3012cc1bbba0b1a3ce92a (patch) | |
tree | 99d092a16eae7b82d6c6b77c85a95277ddda2354 | |
parent | 26f5d608ee01eab380f6eb24b141b7d2a81888fc (diff) |
feat(info): add information about npm modules cache (#15750)
-rw-r--r-- | cli/main.rs | 7 | ||||
-rw-r--r-- | cli/npm/cache.rs | 4 | ||||
-rw-r--r-- | cli/npm/mod.rs | 4 | ||||
-rw-r--r-- | cli/tests/testdata/041_info_flag.out | 1 | ||||
-rw-r--r-- | cli/tests/testdata/041_info_flag_location.out | 1 | ||||
-rw-r--r-- | cli/tests/testdata/info_json.out | 1 | ||||
-rw-r--r-- | cli/tests/testdata/info_json_location.out | 1 |
7 files changed, 19 insertions, 0 deletions
diff --git a/cli/main.rs b/cli/main.rs index bffe9c470..f089eeed6 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -133,6 +133,7 @@ fn print_cache_info( ) -> Result<(), AnyError> { let deno_dir = &state.dir.root; let modules_cache = &state.file_fetcher.get_http_cache_location(); + let npm_cache = &state.npm_resolver.get_cache_location(); let typescript_cache = &state.dir.gen_cache.location; let registry_cache = &state.dir.root.join(lsp::language_server::REGISTRIES_PATH); @@ -149,6 +150,7 @@ fn print_cache_info( let mut output = json!({ "denoDir": deno_dir, "modulesCache": modules_cache, + "npmCache": npm_cache, "typescriptCache": typescript_cache, "registryCache": registry_cache, "originStorage": origin_dir, @@ -172,6 +174,11 @@ fn print_cache_info( ); println!( "{} {}", + colors::bold("npm modules cache:"), + npm_cache.display() + ); + println!( + "{} {}", colors::bold("Emitted modules cache:"), typescript_cache.display() ); diff --git a/cli/npm/cache.rs b/cli/npm/cache.rs index e5193c77c..e39957a6b 100644 --- a/cli/npm/cache.rs +++ b/cli/npm/cache.rs @@ -162,6 +162,10 @@ impl ReadonlyNpmCache { version: NpmVersion::parse(version).unwrap(), }) } + + pub fn get_cache_location(&self) -> PathBuf { + self.root_dir.clone() + } } /// Stores a single copy of npm packages in a cache. diff --git a/cli/npm/mod.rs b/cli/npm/mod.rs index 5b49afb3d..8272974bc 100644 --- a/cli/npm/mod.rs +++ b/cli/npm/mod.rs @@ -184,6 +184,10 @@ impl GlobalNpmPackageResolver { registry_url: self.registry_url.clone(), } } + + pub fn get_cache_location(&self) -> PathBuf { + self.cache.as_readonly().get_cache_location() + } } impl NpmPackageResolver for GlobalNpmPackageResolver { diff --git a/cli/tests/testdata/041_info_flag.out b/cli/tests/testdata/041_info_flag.out index cb94386e8..3506a29e4 100644 --- a/cli/tests/testdata/041_info_flag.out +++ b/cli/tests/testdata/041_info_flag.out @@ -1,5 +1,6 @@ DENO_DIR location: [WILDCARD] Remote modules cache: [WILDCARD]deps +npm modules cache: [WILDCARD]npm Emitted modules cache: [WILDCARD]gen Language server registries cache: [WILDCARD]registries Origin storage: [WILDCARD]location_data diff --git a/cli/tests/testdata/041_info_flag_location.out b/cli/tests/testdata/041_info_flag_location.out index fa111cf18..b9e72f659 100644 --- a/cli/tests/testdata/041_info_flag_location.out +++ b/cli/tests/testdata/041_info_flag_location.out @@ -1,5 +1,6 @@ DENO_DIR location: [WILDCARD] Remote modules cache: [WILDCARD]deps +npm modules cache: [WILDCARD]npm Emitted modules cache: [WILDCARD]gen Language server registries cache: [WILDCARD]registries Origin storage: [WILDCARD]location_data[WILDCARD] diff --git a/cli/tests/testdata/info_json.out b/cli/tests/testdata/info_json.out index 4ba5a95f4..3215af742 100644 --- a/cli/tests/testdata/info_json.out +++ b/cli/tests/testdata/info_json.out @@ -1,6 +1,7 @@ { "denoDir": "[WILDCARD]", "modulesCache": "[WILDCARD]deps", + "npmCache": "[WILDCARD]npm", "typescriptCache": "[WILDCARD]gen", "registryCache": "[WILDCARD]registries", "originStorage": "[WILDCARD]location_data" diff --git a/cli/tests/testdata/info_json_location.out b/cli/tests/testdata/info_json_location.out index 6c4cddefb..510fa7749 100644 --- a/cli/tests/testdata/info_json_location.out +++ b/cli/tests/testdata/info_json_location.out @@ -1,6 +1,7 @@ { "denoDir": "[WILDCARD]", "modulesCache": "[WILDCARD]deps", + "npmCache": "[WILDCARD]npm", "typescriptCache": "[WILDCARD]gen", "registryCache": "[WILDCARD]registries", "originStorage": "[WILDCARD]location_data[WILDCARD]", |