diff --git a/crates/napi/src/env.rs b/crates/napi/src/env.rs index 20849d77..8b8568fc 100644 --- a/crates/napi/src/env.rs +++ b/crates/napi/src/env.rs @@ -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: S)->Result { + let s = self.create_string(script.as_ref())?; + 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 { let global = self.get_global()?;