summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/ops/runtime.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/runtime/ops/runtime.rs b/runtime/ops/runtime.rs
index 70814e3b8..22a481e77 100644
--- a/runtime/ops/runtime.rs
+++ b/runtime/ops/runtime.rs
@@ -1,7 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
use crate::permissions::PermissionsContainer;
-use deno_core::anyhow::Context;
use deno_core::error::AnyError;
use deno_core::op;
use deno_core::Extension;
@@ -20,17 +19,15 @@ pub fn init(main_module: ModuleSpecifier) -> Extension {
#[op]
fn op_main_module(state: &mut OpState) -> Result<String, AnyError> {
- let main = state.borrow::<ModuleSpecifier>().to_string();
- let main_url = deno_core::resolve_url_or_path(&main)?;
+ let main_url = state.borrow::<ModuleSpecifier>();
+ let main_path = main_url.to_string();
if main_url.scheme() == "file" {
- let main_path = std::env::current_dir()
- .context("Failed to get current working directory")?
- .join(main_url.to_string());
+ let main_path = main_url.to_file_path().unwrap();
state
.borrow_mut::<PermissionsContainer>()
.check_read_blind(&main_path, "main_module", "Deno.mainModule")?;
}
- Ok(main)
+ Ok(main_path)
}
pub fn ppid() -> i64 {