diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-13 21:12:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-14 01:12:09 +0000 |
commit | 48ede89f1f192df28cc74822d7bb79b0b4bd0957 (patch) | |
tree | d6dd65cf03152fb0253aba551f7ed016e3b7b09f /cli/proc_state.rs | |
parent | c4771356f27b250e7fdbcede0de5682982720455 (diff) |
refactor(core): resolve_url_or_path and resolve_url_or_path_deprecated (#18170)
This commit changes current "deno_core::resolve_url_or_path" API to
"resolve_url_or_path_deprecated" and adds new "resolve_url_or_path"
API that requires to explicitly pass the directory from which paths
should be resolved to.
Some of the call sites were updated to use the new API, the reminder
of them will be updated in a follow up PR.
Towards landing https://github.com/denoland/deno/pull/15454
Diffstat (limited to 'cli/proc_state.rs')
-rw-r--r-- | cli/proc_state.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs index eb43e75d7..4d8acf524 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -459,7 +459,7 @@ impl ProcState { let specifiers = files .iter() - .map(|file| resolve_url_or_path(file)) + .map(|file| resolve_url_or_path(file, self.options.initial_cwd())) .collect::<Result<Vec<_>, _>>()?; self .prepare_module_load( @@ -495,7 +495,7 @@ impl ProcState { referrer: &str, permissions: &mut PermissionsContainer, ) -> Result<ModuleSpecifier, AnyError> { - if let Ok(referrer) = deno_core::resolve_url_or_path(referrer) { + if let Ok(referrer) = deno_core::resolve_url_or_path_deprecated(referrer) { if self.npm_resolver.in_npm_package(&referrer) { // we're in an npm package, so use node resolution return self @@ -565,10 +565,9 @@ impl ProcState { // but sadly that's not the case due to missing APIs in V8. let is_repl = matches!(self.options.sub_command(), DenoSubcommand::Repl(_)); let referrer = if referrer.is_empty() && is_repl { - let cwd = std::env::current_dir().context("Unable to get CWD")?; - deno_core::resolve_path("./$deno$repl.ts", &cwd)? + deno_core::resolve_path("./$deno$repl.ts", self.options.initial_cwd())? } else { - deno_core::resolve_url_or_path(referrer)? + deno_core::resolve_url_or_path_deprecated(referrer)? }; // FIXME(bartlomieju): this is another hack way to provide NPM specifier |