summaryrefslogtreecommitdiff
path: root/cli/tools/repl/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tools/repl/mod.rs')
-rw-r--r--cli/tools/repl/mod.rs22
1 files changed, 15 insertions, 7 deletions
diff --git a/cli/tools/repl/mod.rs b/cli/tools/repl/mod.rs
index 502105139..cde4efa28 100644
--- a/cli/tools/repl/mod.rs
+++ b/cli/tools/repl/mod.rs
@@ -1,11 +1,13 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
+use crate::args::Flags;
use crate::args::ReplFlags;
use crate::colors;
use crate::proc_state::ProcState;
+use crate::worker::create_main_worker;
use deno_core::error::AnyError;
+use deno_core::resolve_url_or_path;
use deno_runtime::permissions::Permissions;
-use deno_runtime::worker::MainWorker;
use rustyline::error::ReadlineError;
mod cdp;
@@ -76,11 +78,17 @@ async fn read_eval_file(
Ok((*file.source).to_string())
}
-pub async fn run(
- ps: &ProcState,
- worker: MainWorker,
- repl_flags: ReplFlags,
-) -> Result<i32, AnyError> {
+pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> {
+ let main_module = resolve_url_or_path("./$deno$repl.ts").unwrap();
+ let ps = ProcState::build(flags).await?;
+ let mut worker = create_main_worker(
+ &ps,
+ main_module.clone(),
+ Permissions::from_options(&ps.options.permissions_options())?,
+ )
+ .await?;
+ worker.setup_repl().await?;
+ let worker = worker.into_main_worker();
let mut repl_session = ReplSession::initialize(worker).await?;
let mut rustyline_channel = rustyline_channel();
let mut should_exit_on_interrupt = false;
@@ -95,7 +103,7 @@ pub async fn run(
if let Some(eval_files) = repl_flags.eval_files {
for eval_file in eval_files {
- match read_eval_file(ps, &eval_file).await {
+ match read_eval_file(&ps, &eval_file).await {
Ok(eval_source) => {
let output = repl_session
.evaluate_line_and_get_output(&eval_source)