Skip to content

Commit

Permalink
do not forward signals for lifecycle scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Nov 29, 2024
1 parent 3071baf commit 1d2fc91
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
14 changes: 7 additions & 7 deletions cli/npm/managed/resolvers/common/lifecycle_scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use super::bin_entries::BinEntries;
use crate::args::LifecycleScriptsConfig;
use crate::task_runner::run_future_with_kill_signal;
use crate::task_runner::TaskStdio;
use crate::util::progress_bar::ProgressBar;
use deno_core::anyhow::Context;
Expand Down Expand Up @@ -159,17 +158,18 @@ impl<'a> LifecycleScripts<'a> {
progress_bar: &ProgressBar,
) -> Result<(), AnyError> {
let kill_signal = KillSignal::default();
run_future_with_kill_signal(
kill_signal.clone(),
self.finish_with_cancellation(
let _drop_signal = kill_signal.clone().drop_guard();
// we don't run with signals forwarded because once signals
// are setup then they're process wide.
self
.finish_with_cancellation(
snapshot,
packages,
root_node_modules_dir_path,
progress_bar,
kill_signal,
),
)
.await
)
.await
}

async fn finish_with_cancellation(
Expand Down
5 changes: 3 additions & 2 deletions cli/task_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,10 +546,11 @@ fn resolve_managed_npm_commands(
Ok(result)
}

/// Runs a deno task future with the specified kill signal.
/// Runs a deno task future forwarding any signals received
/// to the process.
///
/// Signal listeners and ctrl+c listening will be setup.
pub async fn run_future_with_kill_signal<TOutput>(
pub async fn run_future_forwarding_signals<TOutput>(
kill_signal: KillSignal,
future: impl std::future::Future<Output = TOutput>,
) -> TOutput {
Expand Down
4 changes: 2 additions & 2 deletions cli/tools/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ use crate::colors;
use crate::factory::CliFactory;
use crate::npm::CliNpmResolver;
use crate::task_runner;
use crate::task_runner::run_future_with_kill_signal;
use crate::task_runner::run_future_forwarding_signals;
use crate::util::fs::canonicalize_path;

#[derive(Debug)]
Expand Down Expand Up @@ -229,7 +229,7 @@ pub async fn execute_script(
};

let kill_signal = KillSignal::default();
run_future_with_kill_signal(kill_signal.clone(), async {
run_future_forwarding_signals(kill_signal.clone(), async {
if task_flags.eval {
return task_runner
.run_deno_task(
Expand Down

0 comments on commit 1d2fc91

Please sign in to comment.