From 286ee1d8b68b54d39e698f3b78e3ce9e257fa674 Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Fri, 9 Aug 2019 16:33:59 -0700 Subject: Fix dynamic import base path problem for REPL and eval (#2757) --- cli/worker.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'cli/worker.rs') diff --git a/cli/worker.rs b/cli/worker.rs index db948cc3c..f639c3d6d 100644 --- a/cli/worker.rs +++ b/cli/worker.rs @@ -9,8 +9,10 @@ use deno::RecursiveLoad; use deno::StartupData; use futures::Async; use futures::Future; +use std::env; use std::sync::Arc; use std::sync::Mutex; +use url::Url; /// Wraps deno::Isolate to provide source maps, ops for the CLI, and /// high-level module loading @@ -55,9 +57,11 @@ impl Worker { Self { isolate, state } } - /// Same as execute2() but the filename defaults to "". + /// Same as execute2() but the filename defaults to "$CWD/__anonymous__". pub fn execute(&mut self, js_source: &str) -> Result<(), ErrBox> { - self.execute2("", js_source) + let path = env::current_dir().unwrap().join("__anonymous__"); + let url = Url::from_file_path(path).unwrap(); + self.execute2(url.as_str(), js_source) } /// Executes the provided JavaScript source code. The js_filename argument is -- cgit v1.2.3