1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 05:42:25 -05:00

fix: update message for unsupported schemes with npm and jsr (#26884)

Closes https://github.com/denoland/deno/issues/26596
This commit is contained in:
Bartek Iwańczuk 2024-11-15 17:09:19 +00:00 committed by GitHub
parent b8cf259924
commit dee94473c4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 41 additions and 15 deletions

View file

@ -164,8 +164,19 @@ fn get_validated_scheme(
) -> Result<String, AnyError> {
let scheme = specifier.scheme();
if !SUPPORTED_SCHEMES.contains(&scheme) {
// NOTE(bartlomieju): this message list additional `npm` and `jsr` schemes, but they should actually be handled
// before `file_fetcher.rs` APIs are even hit.
let mut all_supported_schemes = SUPPORTED_SCHEMES.to_vec();
all_supported_schemes.extend_from_slice(&["npm", "jsr"]);
all_supported_schemes.sort();
let scheme_list = all_supported_schemes
.iter()
.map(|scheme| format!(" - \"{}\"", scheme))
.collect::<Vec<_>>()
.join("\n");
Err(generic_error(format!(
"Unsupported scheme \"{scheme}\" for module \"{specifier}\". Supported schemes: {SUPPORTED_SCHEMES:#?}"
"Unsupported scheme \"{scheme}\" for module \"{specifier}\". Supported schemes:\n{}",
scheme_list
)))
} else {
Ok(scheme.to_string())

View file

@ -0,0 +1,5 @@
{
"args": "run np:cowsay",
"output": "main.out",
"exitCode": 1
}

View file

@ -0,0 +1,8 @@
error: Unsupported scheme "np" for module "np:cowsay". Supported schemes:
- "blob"
- "data"
- "file"
- "http"
- "https"
- "jsr"
- "npm"

View file

@ -1,7 +1,8 @@
error: Uncaught (in promise) TypeError: Unsupported scheme "xxx" for module "xxx:". Supported schemes: [
"data",
"blob",
"file",
"http",
"https",
]
error: Uncaught (in promise) TypeError: Unsupported scheme "xxx" for module "xxx:". Supported schemes:
- "blob"
- "data"
- "file"
- "http"
- "https"
- "jsr"
- "npm"

View file

@ -1,8 +1,9 @@
error: Unsupported scheme "ext" for module "ext:runtime/01_errors.js". Supported schemes: [
"data",
"blob",
"file",
"http",
"https",
]
error: Unsupported scheme "ext" for module "ext:runtime/01_errors.js". Supported schemes:
- "blob"
- "data"
- "file"
- "http"
- "https"
- "jsr"
- "npm"
at [WILDCARD]/extension_import.ts:1:8