mirror of
https://github.com/denoland/deno.git
synced 2025-08-02 10:02:23 +00:00
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.
This commit is contained in:
parent
897159dc6e
commit
b3f1f3ba04
8 changed files with 60 additions and 5 deletions
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue