summaryrefslogtreecommitdiff
path: root/cli/tools/task.rs
diff options
context:
space:
mode:
authorSatya Rohith <me@satyarohith.com>2024-08-06 20:35:30 +0530
committerGitHub <noreply@github.com>2024-08-06 20:35:30 +0530
commitb3f1f3ba04e51554ab59d6255bf34a79a9c42bd0 (patch)
tree6455a67387f69c01803e12bc1652eeb0f7dbf7ca /cli/tools/task.rs
parent897159dc6e1b2319cf2f5f09d8d6cecc0d3175fa (diff)
feat: deno run <task> (#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.
Diffstat (limited to 'cli/tools/task.rs')
-rw-r--r--cli/tools/task.rs7
1 files changed, 6 insertions, 1 deletions
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<Flags>,
task_flags: TaskFlags,
+ using_run: bool,
) -> Result<i32, AnyError> {
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(),