summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/file_fetcher.rs13
-rw-r--r--tests/specs/npm/typo_in_npm/__test__.jsonc5
-rw-r--r--tests/specs/npm/typo_in_npm/main.out8
-rw-r--r--tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out15
-rw-r--r--tests/testdata/run/extension_import.ts.out15
5 files changed, 41 insertions, 15 deletions
diff --git a/cli/file_fetcher.rs b/cli/file_fetcher.rs
index 95d778f0b..640f83c35 100644
--- a/cli/file_fetcher.rs
+++ b/cli/file_fetcher.rs
@@ -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())
diff --git a/tests/specs/npm/typo_in_npm/__test__.jsonc b/tests/specs/npm/typo_in_npm/__test__.jsonc
new file mode 100644
index 000000000..03023c9e7
--- /dev/null
+++ b/tests/specs/npm/typo_in_npm/__test__.jsonc
@@ -0,0 +1,5 @@
+{
+ "args": "run np:cowsay",
+ "output": "main.out",
+ "exitCode": 1
+}
diff --git a/tests/specs/npm/typo_in_npm/main.out b/tests/specs/npm/typo_in_npm/main.out
new file mode 100644
index 000000000..19f17b1d0
--- /dev/null
+++ b/tests/specs/npm/typo_in_npm/main.out
@@ -0,0 +1,8 @@
+error: Unsupported scheme "np" for module "np:cowsay". Supported schemes:
+ - "blob"
+ - "data"
+ - "file"
+ - "http"
+ - "https"
+ - "jsr"
+ - "npm"
diff --git a/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out b/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out
index c708fced4..3bff0201f 100644
--- a/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out
+++ b/tests/specs/run/unsupported_dynamic_import_scheme/unsupported_dynamic_import_scheme.out
@@ -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"
diff --git a/tests/testdata/run/extension_import.ts.out b/tests/testdata/run/extension_import.ts.out
index 88039a9ce..0ff656a9c 100644
--- a/tests/testdata/run/extension_import.ts.out
+++ b/tests/testdata/run/extension_import.ts.out
@@ -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