From b3f1f3ba04e51554ab59d6255bf34a79a9c42bd0 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Tue, 6 Aug 2024 20:35:30 +0530 Subject: feat: deno run (#24891) This PR updates `deno run` to fallback to executing tasks when there is no script with the specified name. If there are both script and a task with the same name then `deno run` will prioritise executing the script. --- cli/tools/task.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'cli/tools/task.rs') diff --git a/cli/tools/task.rs b/cli/tools/task.rs index f296a070f..f559ab9b4 100644 --- a/cli/tools/task.rs +++ b/cli/tools/task.rs @@ -12,6 +12,7 @@ use deno_config::deno_json::Task; use deno_config::workspace::TaskOrScript; use deno_config::workspace::WorkspaceDirectory; use deno_config::workspace::WorkspaceTasksConfig; +use deno_core::anyhow::anyhow; use deno_core::anyhow::bail; use deno_core::anyhow::Context; use deno_core::error::AnyError; @@ -28,6 +29,7 @@ use std::sync::Arc; pub async fn execute_script( flags: Arc, task_flags: TaskFlags, + using_run: bool, ) -> Result { let factory = CliFactory::from_flags(flags); let cli_options = factory.cli_options()?; @@ -140,7 +142,10 @@ pub async fn execute_script( } }, None => { - log::error!("Task not found: {task_name}"); + if using_run { + return Err(anyhow!("Task not found: {}", task_name)); + } + log::error!("Task not found: {}", task_name); if log::log_enabled!(log::Level::Error) { print_available_tasks( &mut std::io::stderr(), -- cgit v1.2.3