mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -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:
parent
b8cf259924
commit
dee94473c4
5 changed files with 41 additions and 15 deletions
|
@ -164,8 +164,19 @@ fn get_validated_scheme(
|
||||||
) -> Result<String, AnyError> {
|
) -> Result<String, AnyError> {
|
||||||
let scheme = specifier.scheme();
|
let scheme = specifier.scheme();
|
||||||
if !SUPPORTED_SCHEMES.contains(&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!(
|
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 {
|
} else {
|
||||||
Ok(scheme.to_string())
|
Ok(scheme.to_string())
|
||||||
|
|
5
tests/specs/npm/typo_in_npm/__test__.jsonc
Normal file
5
tests/specs/npm/typo_in_npm/__test__.jsonc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"args": "run np:cowsay",
|
||||||
|
"output": "main.out",
|
||||||
|
"exitCode": 1
|
||||||
|
}
|
8
tests/specs/npm/typo_in_npm/main.out
Normal file
8
tests/specs/npm/typo_in_npm/main.out
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
error: Unsupported scheme "np" for module "np:cowsay". Supported schemes:
|
||||||
|
- "blob"
|
||||||
|
- "data"
|
||||||
|
- "file"
|
||||||
|
- "http"
|
||||||
|
- "https"
|
||||||
|
- "jsr"
|
||||||
|
- "npm"
|
|
@ -1,7 +1,8 @@
|
||||||
error: Uncaught (in promise) TypeError: Unsupported scheme "xxx" for module "xxx:". Supported schemes: [
|
error: Uncaught (in promise) TypeError: Unsupported scheme "xxx" for module "xxx:". Supported schemes:
|
||||||
"data",
|
- "blob"
|
||||||
"blob",
|
- "data"
|
||||||
"file",
|
- "file"
|
||||||
"http",
|
- "http"
|
||||||
"https",
|
- "https"
|
||||||
]
|
- "jsr"
|
||||||
|
- "npm"
|
||||||
|
|
15
tests/testdata/run/extension_import.ts.out
vendored
15
tests/testdata/run/extension_import.ts.out
vendored
|
@ -1,8 +1,9 @@
|
||||||
error: Unsupported scheme "ext" for module "ext:runtime/01_errors.js". Supported schemes: [
|
error: Unsupported scheme "ext" for module "ext:runtime/01_errors.js". Supported schemes:
|
||||||
"data",
|
- "blob"
|
||||||
"blob",
|
- "data"
|
||||||
"file",
|
- "file"
|
||||||
"http",
|
- "http"
|
||||||
"https",
|
- "https"
|
||||||
]
|
- "jsr"
|
||||||
|
- "npm"
|
||||||
at [WILDCARD]/extension_import.ts:1:8
|
at [WILDCARD]/extension_import.ts:1:8
|
||||||
|
|
Loading…
Reference in a new issue