Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add "run_script" for "Env" #1393

Merged
merged 3 commits into from Dec 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/napi/src/env.rs
Expand Up @@ -1020,6 +1020,13 @@ impl Env {
check_status!(unsafe { sys::napi_close_handle_scope(self.0, handle_scope) })?;
result
}

pub fn run_script(&self, script: &str)->Result<JsObject> {
F001 marked this conversation as resolved.
Show resolved Hide resolved
let s = self.create_string(script)?;
let mut raw_value = ptr::null_mut();
check_status!(unsafe { sys::napi_run_script(self.0, s.raw(), &mut raw_value) })?;
Ok(unsafe { JsObject::from_raw_unchecked(self.0, raw_value) })
}

pub fn get_napi_version(&self) -> Result<u32> {
let global = self.get_global()?;
Expand Down