summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/compiler.rs4
-rw-r--r--cli/deno_error.rs3
-rw-r--r--cli/flags.rs4
-rw-r--r--cli/import_map.rs4
-rw-r--r--cli/msg.fbs3
-rw-r--r--cli/ops.rs2
-rw-r--r--cli/state.rs5
-rw-r--r--cli/worker.rs10
8 files changed, 19 insertions, 16 deletions
diff --git a/cli/compiler.rs b/cli/compiler.rs
index 872ed28a2..c7adbe390 100644
--- a/cli/compiler.rs
+++ b/cli/compiler.rs
@@ -249,7 +249,7 @@ mod tests {
tokio_util::init(|| {
let specifier = "./tests/002_hello.ts";
use deno::ModuleSpecifier;
- let module_name = ModuleSpecifier::resolve_root(specifier)
+ let module_name = ModuleSpecifier::resolve_url_or_path(specifier)
.unwrap()
.to_string();
@@ -296,7 +296,7 @@ mod tests {
fn test_bundle_async() {
let specifier = "./tests/002_hello.ts";
use deno::ModuleSpecifier;
- let module_name = ModuleSpecifier::resolve_root(specifier)
+ let module_name = ModuleSpecifier::resolve_url_or_path(specifier)
.unwrap()
.to_string();
diff --git a/cli/deno_error.rs b/cli/deno_error.rs
index 2e683c504..6f11a6879 100644
--- a/cli/deno_error.rs
+++ b/cli/deno_error.rs
@@ -110,7 +110,8 @@ impl DenoError {
use ModuleResolutionError::*;
match err {
InvalidUrl(err) | InvalidBaseUrl(err) => Self::url_error_kind(err),
- ImportPathPrefixMissing => ErrorKind::ImportPathPrefixMissing,
+ InvalidPath => ErrorKind::InvalidPath,
+ ImportPrefixMissing => ErrorKind::ImportPrefixMissing,
}
}
Repr::Diagnostic(ref _err) => ErrorKind::Diagnostic,
diff --git a/cli/flags.rs b/cli/flags.rs
index 4d68ac726..b3fc11380 100644
--- a/cli/flags.rs
+++ b/cli/flags.rs
@@ -630,7 +630,9 @@ pub enum DenoSubcommand {
fn get_default_bundle_filename(source_file: &str) -> String {
use deno::ModuleSpecifier;
- let url = ModuleSpecifier::resolve_root(source_file).unwrap().to_url();
+ let url = ModuleSpecifier::resolve_url_or_path(source_file)
+ .unwrap()
+ .to_url();
let path_segments = url.path_segments().unwrap();
let last = path_segments.last().unwrap();
String::from(last.trim_end_matches(".ts").trim_end_matches(".js"))
diff --git a/cli/import_map.rs b/cli/import_map.rs
index 4321cacad..44525f7a2 100644
--- a/cli/import_map.rs
+++ b/cli/import_map.rs
@@ -178,9 +178,7 @@ impl ImportMap {
continue;
}
- let normalized_address = ModuleSpecifier::resolve(&url_string, ".")
- .expect("Address should be valid module specifier");
- normalized_addresses.push(normalized_address);
+ normalized_addresses.push(url.into());
}
normalized_addresses
diff --git a/cli/msg.fbs b/cli/msg.fbs
index da181af43..df85a4072 100644
--- a/cli/msg.fbs
+++ b/cli/msg.fbs
@@ -102,6 +102,7 @@ enum ErrorKind: byte {
WouldBlock,
InvalidInput,
InvalidData,
+ InvalidPath,
TimedOut,
Interrupted,
WriteZero,
@@ -141,7 +142,7 @@ enum ErrorKind: byte {
NoAsyncSupport,
NoSyncSupport,
ImportMapError,
- ImportPathPrefixMissing,
+ ImportPrefixMissing,
// other kinds
Diagnostic,
diff --git a/cli/ops.rs b/cli/ops.rs
index 0664d8077..218fb996e 100644
--- a/cli/ops.rs
+++ b/cli/ops.rs
@@ -2053,7 +2053,7 @@ fn op_create_worker(
err_check(worker.execute("denoMain()"));
err_check(worker.execute("workerMain()"));
- let module_specifier = ModuleSpecifier::resolve_root(specifier)?;
+ let module_specifier = ModuleSpecifier::resolve_url_or_path(specifier)?;
let op =
worker
diff --git a/cli/state.rs b/cli/state.rs
index fd209a0f2..056226511 100644
--- a/cli/state.rs
+++ b/cli/state.rs
@@ -170,7 +170,8 @@ impl Loader for ThreadSafeState {
}
}
- ModuleSpecifier::resolve(specifier, referrer).map_err(DenoError::from)
+ ModuleSpecifier::resolve_import(specifier, referrer)
+ .map_err(DenoError::from)
}
/// Given an absolute url, load its source code.
@@ -252,7 +253,7 @@ impl ThreadSafeState {
None
} else {
let root_specifier = argv_rest[1].clone();
- match ModuleSpecifier::resolve_root(&root_specifier) {
+ match ModuleSpecifier::resolve_url_or_path(&root_specifier) {
Ok(specifier) => Some(specifier),
Err(e) => {
// TODO: handle unresolvable specifier
diff --git a/cli/worker.rs b/cli/worker.rs
index 65da666e8..1cf38e295 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -141,7 +141,7 @@ mod tests {
#[test]
fn execute_mod_esm_imports_a() {
let module_specifier =
- ModuleSpecifier::resolve_root("tests/esm_imports_a.js").unwrap();
+ ModuleSpecifier::resolve_url_or_path("tests/esm_imports_a.js").unwrap();
let argv = vec![String::from("./deno"), module_specifier.to_string()];
let state = ThreadSafeState::new(
flags::DenoFlags::default(),
@@ -169,7 +169,7 @@ mod tests {
#[test]
fn execute_mod_circular() {
let module_specifier =
- ModuleSpecifier::resolve_root("tests/circular1.js").unwrap();
+ ModuleSpecifier::resolve_url_or_path("tests/circular1.js").unwrap();
let argv = vec![String::from("./deno"), module_specifier.to_string()];
let state = ThreadSafeState::new(
flags::DenoFlags::default(),
@@ -197,7 +197,7 @@ mod tests {
#[test]
fn execute_006_url_imports() {
let module_specifier =
- ModuleSpecifier::resolve_root("tests/006_url_imports.ts").unwrap();
+ ModuleSpecifier::resolve_url_or_path("tests/006_url_imports.ts").unwrap();
let argv = vec![String::from("deno"), module_specifier.to_string()];
let mut flags = flags::DenoFlags::default();
flags.reload = true;
@@ -327,7 +327,7 @@ mod tests {
// "foo" is not a valid module specifier so this should return an error.
let mut worker = create_test_worker();
let module_specifier =
- ModuleSpecifier::resolve_root("does-not-exist").unwrap();
+ ModuleSpecifier::resolve_url_or_path("does-not-exist").unwrap();
let result = worker.execute_mod_async(&module_specifier, false).wait();
assert!(result.is_err());
})
@@ -340,7 +340,7 @@ mod tests {
// tests).
let mut worker = create_test_worker();
let module_specifier =
- ModuleSpecifier::resolve_root("./tests/002_hello.ts").unwrap();
+ ModuleSpecifier::resolve_url_or_path("./tests/002_hello.ts").unwrap();
let result = worker.execute_mod_async(&module_specifier, false).wait();
assert!(result.is_ok());
})