k-xoK
Denoβ€’3y agoβ€’
6 replies
k-xo

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(())
    }


I was wondering how I could modify this to return the result of the executed javascript?
Was this page helpful?