Skip to content

Commit 24cb6c7

Browse files
authored
fix: do not have duplicate progress bars for post install scripts (#30489)
1 parent 3af338e commit 24cb6c7

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

cli/factory.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -562,10 +562,12 @@ impl CliFactory {
562562
self.text_only_progress_bar().clone(),
563563
)),
564564
match resolver_factory.npm_resolver()?.as_managed() {
565-
Some(managed_npm_resolver) => Arc::new(
566-
DenoTaskLifeCycleScriptsExecutor::new(managed_npm_resolver.clone()),
567-
)
568-
as Arc<dyn LifecycleScriptsExecutor>,
565+
Some(managed_npm_resolver) => {
566+
Arc::new(DenoTaskLifeCycleScriptsExecutor::new(
567+
managed_npm_resolver.clone(),
568+
self.text_only_progress_bar().clone(),
569+
)) as Arc<dyn LifecycleScriptsExecutor>
570+
}
569571
None => Arc::new(NullLifecycleScriptsExecutor),
570572
},
571573
self.text_only_progress_bar().clone(),

cli/npm.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ pub enum DenoTaskLifecycleScriptsError {
275275
}
276276

277277
pub struct DenoTaskLifeCycleScriptsExecutor {
278+
progress_bar: ProgressBar,
278279
npm_resolver: ManagedNpmResolverRc<CliSys>,
279280
}
280281

@@ -348,10 +349,7 @@ impl LifecycleScriptsExecutor for DenoTaskLifeCycleScriptsExecutor {
348349
{
349350
continue;
350351
}
351-
let pb = ProgressBar::new(
352-
crate::util::progress_bar::ProgressBarStyle::TextOnly,
353-
);
354-
let _guard = pb.update_with_prompt(
352+
let _guard = self.progress_bar.update_with_prompt(
355353
ProgressMessagePrompt::Initialize,
356354
&format!("{}: running '{script_name}' script", package.id.nv),
357355
);
@@ -444,8 +442,14 @@ impl LifecycleScriptsExecutor for DenoTaskLifeCycleScriptsExecutor {
444442
}
445443

446444
impl DenoTaskLifeCycleScriptsExecutor {
447-
pub fn new(npm_resolver: ManagedNpmResolverRc<CliSys>) -> Self {
448-
Self { npm_resolver }
445+
pub fn new(
446+
npm_resolver: ManagedNpmResolverRc<CliSys>,
447+
progress_bar: ProgressBar,
448+
) -> Self {
449+
Self {
450+
npm_resolver,
451+
progress_bar,
452+
}
449453
}
450454

451455
// take in all (non copy) packages from snapshot,

0 commit comments

Comments
 (0)