diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-14 16:47:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 16:47:09 -0400 |
commit | 96ea5b1d3d7b4ddec386d8708dc8a01c5fa946e9 (patch) | |
tree | 6c0209413506bce00494dafda93f7c9026e917b6 /core/ops_builtin_v8.rs | |
parent | eb990efcce1e5390e4ed76b858c05c6f9b3b6c11 (diff) |
refactor: deno_core not using std::env::current_dir (#18173)
This commit changes "deno_core" to not rely on implicitly calling
"std::env::current_dir()" when resolving module specifiers using
APIs from "deno_core::modules_specifier".
Supersedes https://github.com/denoland/deno/pull/15454
Diffstat (limited to 'core/ops_builtin_v8.rs')
-rw-r--r-- | core/ops_builtin_v8.rs | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/core/ops_builtin_v8.rs b/core/ops_builtin_v8.rs index c66e4d3c2..05250dc73 100644 --- a/core/ops_builtin_v8.rs +++ b/core/ops_builtin_v8.rs @@ -6,14 +6,13 @@ use crate::error::range_error; use crate::error::type_error; use crate::error::JsError; use crate::ops_builtin::WasmStreamingResource; -use crate::resolve_url_or_path; +use crate::resolve_url; use crate::serde_v8::from_v8; use crate::source_map::apply_source_map as apply_source_map_; use crate::JsRealm; use crate::JsRuntime; use crate::OpDecl; use crate::ZeroCopyBuf; -use anyhow::Context; use anyhow::Error; use deno_ops::op; use serde::Deserialize; @@ -160,20 +159,12 @@ struct EvalContextResult<'s>( fn op_eval_context<'a>( scope: &mut v8::HandleScope<'a>, source: serde_v8::Value<'a>, - specifier: Option<String>, + specifier: String, ) -> Result<EvalContextResult<'a>, Error> { let tc_scope = &mut v8::TryCatch::new(scope); let source = v8::Local::<v8::String>::try_from(source.v8_value) .map_err(|_| type_error("Invalid source"))?; - let specifier = match specifier { - Some(s) => { - // TODO(bartlomieju): ideally we shouldn't need to call `current_dir()` on each - // call - maybe it should be caller's responsibility to pass fully resolved URL? - let cwd = std::env::current_dir().context("Unable to get CWD")?; - resolve_url_or_path(&s, &cwd)?.to_string() - } - None => crate::DUMMY_SPECIFIER.to_string(), - }; + let specifier = resolve_url(&specifier)?.to_string(); let specifier = v8::String::new(tc_scope, &specifier).unwrap(); let origin = script_origin(tc_scope, specifier); |