1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-26 00:59:24 -05:00

fix(task): support tasks with colons in name in deno run (#25233)

Fix task names containing a colon not being found with `deno run`. We
were only checking for a `module not found` error message, but strings
containing a colon throw a different error.

Fixes https://github.com/denoland/deno/issues/25232
This commit is contained in:
Marvin Hagemeister 2024-08-27 11:27:10 +02:00 committed by Luca Casonato
parent bb5d7d9ed6
commit 1d2116d94a
No known key found for this signature in database
GPG key ID: 01A83EB62563811F
5 changed files with 12 additions and 2 deletions

View file

@ -53,6 +53,7 @@ use deno_runtime::tokio_util::create_and_run_current_thread_with_maybe_metrics;
use deno_terminal::colors; use deno_terminal::colors;
use factory::CliFactory; use factory::CliFactory;
use standalone::MODULE_NOT_FOUND; use standalone::MODULE_NOT_FOUND;
use standalone::UNSUPPORTED_SCHEME;
use std::env; use std::env;
use std::future::Future; use std::future::Future;
use std::ops::Deref; use std::ops::Deref;
@ -196,7 +197,8 @@ async fn run_subcommand(flags: Arc<Flags>) -> Result<i32, AnyError> {
match result { match result {
Ok(v) => Ok(v), Ok(v) => Ok(v),
Err(script_err) => { Err(script_err) => {
if script_err.to_string().starts_with(MODULE_NOT_FOUND) { let script_err_msg = script_err.to_string();
if script_err_msg.starts_with(MODULE_NOT_FOUND) || script_err_msg.starts_with(UNSUPPORTED_SCHEME) {
if run_flags.bare { if run_flags.bare {
let mut cmd = args::clap_root(); let mut cmd = args::clap_root();
cmd.build(); cmd.build();

View file

@ -133,6 +133,7 @@ struct EmbeddedModuleLoader {
} }
pub const MODULE_NOT_FOUND: &str = "Module not found"; pub const MODULE_NOT_FOUND: &str = "Module not found";
pub const UNSUPPORTED_SCHEME: &str = "Unsupported scheme";
impl ModuleLoader for EmbeddedModuleLoader { impl ModuleLoader for EmbeddedModuleLoader {
fn resolve( fn resolve(

View file

@ -8,6 +8,10 @@
"args": "run not_found", "args": "run not_found",
"output": "not_found.out", "output": "not_found.out",
"exitCode": 1 "exitCode": 1
},
"deno_run_task_colon": {
"args": "run main:foo",
"output": "main_foo.out"
} }
} }
} }

View file

@ -1,5 +1,6 @@
{ {
"tasks": { "tasks": {
"main": "deno run main.ts" "main": "deno run main.ts",
"main:foo": "deno run main.ts"
} }
} }

View file

@ -0,0 +1,2 @@
Task main:foo deno run main.ts
main