Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang committed Apr 18, 2024
1 parent 3aedaaa commit 2152b42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
12 changes: 12 additions & 0 deletions crates/turborepo-lib/src/run/builder.rs
Expand Up @@ -59,6 +59,7 @@ pub struct RunBuilder {
experimental_ui: bool,
api_client: APIClient,
analytics_sender: Option<AnalyticsSender>,
should_print_prelude: Option<bool>,
}

impl RunBuilder {
Expand Down Expand Up @@ -108,6 +109,7 @@ impl RunBuilder {
version,
experimental_ui,
analytics_sender: None,
should_print_prelude: None,
})
}

Expand All @@ -124,6 +126,11 @@ impl RunBuilder {
self
}

pub fn hide_prelude(mut self) -> Self {
self.should_print_prelude = Some(false);
self
}

// Starts analytics and returns handle. This is not included in the main `build`
// function because we don't want the handle stored in the `Run` struct.
pub fn start_analytics(&self) -> (Option<AnalyticsSender>, Option<AnalyticsHandle>) {
Expand Down Expand Up @@ -377,6 +384,10 @@ impl RunBuilder {
self.opts.run_opts.env_mode = EnvMode::Strict;
}

let should_print_prelude = self
.should_print_prelude
.unwrap_or(self.opts.run_opts.dry_run.is_none() && self.opts.run_opts.graph.is_none());

Ok(Run {
version: self.version,
ui: self.ui,
Expand All @@ -397,6 +408,7 @@ impl RunBuilder {
engine: Arc::new(engine),
run_cache,
signal_handler: signal_handler.clone(),
should_print_prelude,
})
}

Expand Down
3 changes: 2 additions & 1 deletion crates/turborepo-lib/src/run/mod.rs
Expand Up @@ -61,6 +61,7 @@ pub struct Run {
signal_handler: SignalHandler,
engine: Arc<Engine>,
task_access: TaskAccess,
should_print_prelude: bool,
}

impl Run {
Expand Down Expand Up @@ -115,7 +116,7 @@ impl Run {
}

pub async fn run(&self) -> Result<i32, Error> {
if self.opts.run_opts.dry_run.is_none() && self.opts.run_opts.graph.is_none() {
if self.should_print_prelude {
self.print_run_prelude();
}
if let Some(subscriber) = self.signal_handler.subscribe() {
Expand Down
2 changes: 1 addition & 1 deletion crates/turborepo-lib/src/run/watch.rs
Expand Up @@ -180,7 +180,7 @@ impl WatchClient {
current_runs.insert(
package_name,
tokio::spawn(async move {
let mut run = RunBuilder::new(new_base)?
let run = RunBuilder::new(new_base)?
.build(&handler, telemetry)
.await?;
run.run().await
Expand Down

0 comments on commit 2152b42

Please sign in to comment.