diff --git a/crates/dash_node_impl/src/native.rs b/crates/dash_node_impl/src/native.rs index f2167c2a..9b666e52 100644 --- a/crates/dash_node_impl/src/native.rs +++ b/crates/dash_node_impl/src/native.rs @@ -1,7 +1,7 @@ use dash_vm::localscope::LocalScope; -use dash_vm::value::object::NamedObject; -use dash_vm::value::string::JsString; use dash_vm::value::Value; +use dash_vm::value::object::{NamedObject, Object, PropertyValue}; +use dash_vm::value::string::JsString; use crate::state::state_mut; @@ -39,7 +39,7 @@ pub fn load_native_module(sc: &mut LocalScope<'_>, arg: JsString) -> Result (state_mut(sc).assert_cache, crate::assert::init_module), - state.sym.fs => (state_mut(sc).fs_cache, dash_rt_fs::sync::init_module), + state.sym.fs => (state_mut(sc).fs_cache, init_fs_module), state.sym.fetch => (state_mut(sc).fetch_cache, dash_rt_fetch::init_module), state.sym.path => (state_mut(sc).path_cache, crate::path::init_module), state.sym.events => (state_mut(sc).events_cache, crate::events::init_module), @@ -64,3 +64,11 @@ fn init_dummy_empty_module(sc: &mut LocalScope<'_>) -> Result { fn init_timers_module(sc: &mut LocalScope<'_>) -> Result { dash_rt_timers::import(sc) } + +fn init_fs_module(sc: &mut LocalScope<'_>) -> Result { + let sync = dash_rt_fs::sync::init_module(sc)?; + let promises = dash_rt_fs::promises::init_module(sc)?; + let key = state_mut(sc).sym.promises; + sync.set_property(sc, key.into(), PropertyValue::static_default(promises))?; + Ok(sync) +} diff --git a/crates/dash_node_impl/src/symbols.rs b/crates/dash_node_impl/src/symbols.rs index 25995daa..e22420ea 100644 --- a/crates/dash_node_impl/src/symbols.rs +++ b/crates/dash_node_impl/src/symbols.rs @@ -33,5 +33,6 @@ define_symbol_set!(#[derive(Trace)] NodeSymbols => [ alloc, writeUInt32BE, writeUInt32LE, - setTimeout + setTimeout, + promises ]);