k-xo
k-xo
DDeno
Created by k-xo on 9/22/2023 in #help
Return results from execute_main_module
I currently have this function to run some execute some js
pub async fn run(&self, path_to_main_module: &Path) -> Result<()> {
let main_module = ModuleSpecifier::from_file_path(path_to_main_module).map_err(|_| {
anyhow::anyhow!(
"Failed to create module specifier from path: {:?}",
path_to_main_module
)
})?;

let mut main_worker = deno_runtime::worker::MainWorker::bootstrap_from_options(
main_module.clone(),
PermissionsContainer::new(Permissions {
write: UnaryPermission::default(),
read: UnaryPermission::default(),
ffi: UnaryPermission::default(),
env: UnaryPermission::default(),
..Permissions::allow_all()
}),
Default::default(),
);

main_worker.execute_main_module(&main_module).await?;
Ok(())
}
pub async fn run(&self, path_to_main_module: &Path) -> Result<()> {
let main_module = ModuleSpecifier::from_file_path(path_to_main_module).map_err(|_| {
anyhow::anyhow!(
"Failed to create module specifier from path: {:?}",
path_to_main_module
)
})?;

let mut main_worker = deno_runtime::worker::MainWorker::bootstrap_from_options(
main_module.clone(),
PermissionsContainer::new(Permissions {
write: UnaryPermission::default(),
read: UnaryPermission::default(),
ffi: UnaryPermission::default(),
env: UnaryPermission::default(),
..Permissions::allow_all()
}),
Default::default(),
);

main_worker.execute_main_module(&main_module).await?;
Ok(())
}
I was wondering how I could modify this to return the result of the executed javascript?
7 replies