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:
parent
bb5d7d9ed6
commit
1d2116d94a
5 changed files with 12 additions and 2 deletions
|
@ -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();
|
||||||
|
|
|
@ -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(
|
||||||
|
|
|
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"tasks": {
|
"tasks": {
|
||||||
"main": "deno run main.ts"
|
"main": "deno run main.ts",
|
||||||
|
"main:foo": "deno run main.ts"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
tests/specs/run/run_task/main_foo.out
Normal file
2
tests/specs/run/run_task/main_foo.out
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Task main:foo deno run main.ts
|
||||||
|
main
|
Loading…
Reference in a new issue