diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-09-09 21:57:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-09 15:57:39 -0400 |
commit | f92bd986de7f083ac164c0e3a2b04d3504c29741 (patch) | |
tree | dbd0a3484014da69ab8258c5f8e86616574741af /cli/npm/registry.rs | |
parent | 3bce2af0ebc997278519f5d6270915bb3fe8fd56 (diff) |
feat: download progress bar (#15814)
Diffstat (limited to 'cli/npm/registry.rs')
-rw-r--r-- | cli/npm/registry.rs | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/cli/npm/registry.rs b/cli/npm/registry.rs index 1fb4b2e0a..f5b8b9fc8 100644 --- a/cli/npm/registry.rs +++ b/cli/npm/registry.rs @@ -21,6 +21,7 @@ use serde::Serialize; use crate::file_fetcher::CacheSetting; use crate::fs_util; use crate::http_cache::CACHE_PERM; +use crate::progress_bar::ProgressBar; use super::cache::NpmCache; use super::semver::NpmVersionReq; @@ -106,6 +107,7 @@ pub struct NpmRegistryApi { mem_cache: Arc<Mutex<HashMap<String, Option<NpmPackageInfo>>>>, reload: bool, cache_setting: CacheSetting, + progress_bar: ProgressBar, } impl NpmRegistryApi { @@ -132,8 +134,15 @@ impl NpmRegistryApi { cache: NpmCache, reload: bool, cache_setting: CacheSetting, + progress_bar: ProgressBar, ) -> Self { - Self::from_base(Self::default_url(), cache, reload, cache_setting) + Self::from_base( + Self::default_url(), + cache, + reload, + cache_setting, + progress_bar, + ) } pub fn from_base( @@ -141,6 +150,7 @@ impl NpmRegistryApi { cache: NpmCache, reload: bool, cache_setting: CacheSetting, + progress_bar: ProgressBar, ) -> Self { Self { base_url, @@ -148,6 +158,7 @@ impl NpmRegistryApi { mem_cache: Default::default(), reload, cache_setting, + progress_bar, } } @@ -294,13 +305,7 @@ impl NpmRegistryApi { } let package_url = self.get_package_url(name); - - log::log!( - log::Level::Info, - "{} {}", - colors::green("Download"), - package_url, - ); + let _guard = self.progress_bar.update(package_url.as_str()); let response = match reqwest::get(package_url).await { Ok(response) => response, |