From a6c47ee74023f6ef683988cabc8caa95406e3c99 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Fri, 5 May 2023 12:44:24 -0400 Subject: refactor(ext/node): combine `deno_node::Fs` with `deno_fs::FileSystem` (#18991) --- runtime/build.rs | 8 +++----- runtime/web_worker.rs | 8 +++++--- runtime/worker.rs | 9 +++++---- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'runtime') diff --git a/runtime/build.rs b/runtime/build.rs index d096df7db..4f49ba681 100644 --- a/runtime/build.rs +++ b/runtime/build.rs @@ -273,6 +273,7 @@ mod startup_snapshot { pub fn create_runtime_snapshot(snapshot_path: PathBuf) { // NOTE(bartlomieju): ordering is important here, keep it in sync with // `runtime/worker.rs`, `runtime/web_worker.rs` and `cli/build.rs`! + let fs = std::sync::Arc::new(deno_fs::RealFs); let extensions: Vec = vec![ deno_webidl::deno_webidl::init_ops_and_esm(), deno_console::deno_console::init_ops_and_esm(), @@ -309,14 +310,11 @@ mod startup_snapshot { deno_napi::deno_napi::init_ops_and_esm::(), deno_http::deno_http::init_ops_and_esm(), deno_io::deno_io::init_ops_and_esm(Default::default()), - deno_fs::deno_fs::init_ops_and_esm::( - false, - std::sync::Arc::new(deno_fs::RealFs), - ), + deno_fs::deno_fs::init_ops_and_esm::(false, fs.clone()), runtime::init_ops_and_esm(), // FIXME(bartlomieju): these extensions are specified last, because they // depend on `runtime`, even though it should be other way around - deno_node::deno_node::init_ops_and_esm::(None, None), + deno_node::deno_node::init_ops_and_esm::(None, fs), #[cfg(not(feature = "snapshot_from_snapshot"))] runtime_main::init_ops_and_esm(), ]; diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index e485c0c35..6487239f8 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -333,7 +333,6 @@ pub struct WebWorkerOptions { pub seed: Option, pub fs: Arc, pub module_loader: Rc, - pub node_fs: Option>, pub npm_resolver: Option>, pub create_web_worker_cb: Arc, pub preload_module_cb: Arc, @@ -442,10 +441,13 @@ impl WebWorker { deno_napi::deno_napi::init_ops::(), deno_http::deno_http::init_ops(), deno_io::deno_io::init_ops(Some(options.stdio)), - deno_fs::deno_fs::init_ops::(unstable, options.fs), + deno_fs::deno_fs::init_ops::( + unstable, + options.fs.clone(), + ), deno_node::deno_node::init_ops::( options.npm_resolver, - options.node_fs, + options.fs, ), // Runtime ops that are always initialized for WebWorkers ops::web_worker::deno_web_worker::init_ops(), diff --git a/runtime/worker.rs b/runtime/worker.rs index b9db21780..77f16553b 100644 --- a/runtime/worker.rs +++ b/runtime/worker.rs @@ -94,7 +94,6 @@ pub struct WorkerOptions { /// If not provided runtime will error if code being /// executed tries to load modules. pub module_loader: Rc, - pub node_fs: Option>, pub npm_resolver: Option>, // Callbacks invoked when creating new instance of WebWorker pub create_web_worker_cb: Arc, @@ -166,7 +165,6 @@ impl Default for WorkerOptions { broadcast_channel: Default::default(), source_map_getter: Default::default(), root_cert_store_provider: Default::default(), - node_fs: Default::default(), npm_resolver: Default::default(), blob_store: Default::default(), extensions: Default::default(), @@ -268,10 +266,13 @@ impl MainWorker { deno_napi::deno_napi::init_ops::(), deno_http::deno_http::init_ops(), deno_io::deno_io::init_ops(Some(options.stdio)), - deno_fs::deno_fs::init_ops::(unstable, options.fs), + deno_fs::deno_fs::init_ops::( + unstable, + options.fs.clone(), + ), deno_node::deno_node::init_ops::( options.npm_resolver, - options.node_fs, + options.fs, ), // Ops from this crate ops::runtime::deno_runtime::init_ops(main_module.clone()), -- cgit v1.2.3