From 7a65b8e8dae8660f0e40130ba5a63f6c10d358c6 Mon Sep 17 00:00:00 2001 From: nasa Date: Tue, 25 Oct 2022 01:40:27 +0900 Subject: [PATCH] fix(cli): Fixed bug where the progress bar did not clear (#16401) --- cli/proc_state.rs | 3 ++- cli/progress_bar.rs | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/cli/proc_state.rs b/cli/proc_state.rs index 95520ffded..49ee5d8f45 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -292,6 +292,7 @@ impl ProcState { dynamic_permissions: Permissions, reload_on_watch: bool, ) -> Result<(), AnyError> { + let _pb_clear_guard = self.progress_bar.clear_guard(); let roots = roots .into_iter() .map(|s| (s, ModuleKind::Esm)) @@ -412,7 +413,7 @@ impl ProcState { self.prepare_node_std_graph().await?; } - self.progress_bar.clear(); + drop(_pb_clear_guard); // type check if necessary if self.options.type_check_mode() != TypeCheckMode::None { diff --git a/cli/progress_bar.rs b/cli/progress_bar.rs index 36cdff7c66..5b49fb2795 100644 --- a/cli/progress_bar.rs +++ b/cli/progress_bar.rs @@ -126,4 +126,18 @@ impl ProgressBar { inner.pb = None; } } + + pub fn clear_guard(&self) -> ClearGuard { + ClearGuard { pb: self.clone() } + } +} + +pub struct ClearGuard { + pb: ProgressBar, +} + +impl Drop for ClearGuard { + fn drop(&mut self) { + self.pb.clear(); + } }