diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2019-08-09 16:33:59 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-08-09 16:33:59 -0700 |
commit | 286ee1d8b68b54d39e698f3b78e3ce9e257fa674 (patch) | |
tree | 550ee67d44d9a1e920e5010bb7b1551943c008ff /cli/worker.rs | |
parent | 83d5362f1d7d8589b862de57912135067a8278c7 (diff) |
Fix dynamic import base path problem for REPL and eval (#2757)
Diffstat (limited to 'cli/worker.rs')
-rw-r--r-- | cli/worker.rs | 8 |
1 files changed, 6 insertions, 2 deletions
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 "<anonymous>". + /// Same as execute2() but the filename defaults to "$CWD/__anonymous__". pub fn execute(&mut self, js_source: &str) -> Result<(), ErrBox> { - self.execute2("<anonymous>", 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 |