summaryrefslogtreecommitdiff
path: root/cli/tools/repl
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2023-03-13 21:12:09 -0400
committerGitHub <noreply@github.com>2023-03-14 01:12:09 +0000
commit48ede89f1f192df28cc74822d7bb79b0b4bd0957 (patch)
treed6dd65cf03152fb0253aba551f7ed016e3b7b09f /cli/tools/repl
parentc4771356f27b250e7fdbcede0de5682982720455 (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/tools/repl')
-rw-r--r--cli/tools/repl/mod.rs8
-rw-r--r--cli/tools/repl/session.rs8
2 files changed, 9 insertions, 7 deletions
diff --git a/cli/tools/repl/mod.rs b/cli/tools/repl/mod.rs
index 99dab6261..7224eb45f 100644
--- a/cli/tools/repl/mod.rs
+++ b/cli/tools/repl/mod.rs
@@ -5,7 +5,6 @@ use crate::args::ReplFlags;
use crate::colors;
use crate::proc_state::ProcState;
use crate::worker::create_main_worker;
-use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::resolve_path;
use deno_runtime::permissions::Permissions;
@@ -70,7 +69,8 @@ async fn read_eval_file(
ps: &ProcState,
eval_file: &str,
) -> Result<String, AnyError> {
- let specifier = deno_core::resolve_url_or_path(eval_file)?;
+ let specifier =
+ deno_core::resolve_url_or_path(eval_file, ps.options.initial_cwd())?;
let file = ps
.file_fetcher
@@ -81,9 +81,9 @@ async fn read_eval_file(
}
pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> {
- let cwd = std::env::current_dir().context("Unable to get CWD")?;
- let main_module = resolve_path("./$deno$repl.ts", &cwd).unwrap();
let ps = ProcState::build(flags).await?;
+ let main_module =
+ resolve_path("./$deno$repl.ts", ps.options.initial_cwd()).unwrap();
let mut worker = create_main_worker(
&ps,
main_module,
diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs
index 1cd67fc97..3cd9730a7 100644
--- a/cli/tools/repl/session.rs
+++ b/cli/tools/repl/session.rs
@@ -11,7 +11,6 @@ use deno_ast::swc::visit::VisitWith;
use deno_ast::DiagnosticsError;
use deno_ast::ImportsNotUsedAsValues;
use deno_ast::ModuleSpecifier;
-use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::futures::channel::mpsc::UnboundedReceiver;
use deno_core::futures::FutureExt;
@@ -144,8 +143,11 @@ impl ReplSession {
}
assert_ne!(context_id, 0);
- let cwd = std::env::current_dir().context("Unable to get CWD")?;
- let referrer = deno_core::resolve_path("./$deno$repl.ts", &cwd).unwrap();
+ let referrer = deno_core::resolve_path(
+ "./$deno$repl.ts",
+ proc_state.options.initial_cwd(),
+ )
+ .unwrap();
let mut repl_session = ReplSession {
proc_state,