diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-07-01 18:00:14 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-02 00:00:14 +0000 |
commit | e746b6d80654ba4e4e26370fe6e4f784ce841d92 (patch) | |
tree | 153ffad92a96126b9ab8e906dcdabf7648755931 /core/examples/fs_module_loader.rs | |
parent | b9c0e7cd550ab14fa7da7e33ed87cbeeeb9785a0 (diff) |
refactor(core): Extract deno_core (#19658)
`deno_core` is moving out! You'll find it at
https://github.com/denoland/deno_core/ once this PR lands.
Diffstat (limited to 'core/examples/fs_module_loader.rs')
-rw-r--r-- | core/examples/fs_module_loader.rs | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/core/examples/fs_module_loader.rs b/core/examples/fs_module_loader.rs deleted file mode 100644 index 737ff1d5c..000000000 --- a/core/examples/fs_module_loader.rs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. - -use anyhow::Context; -use deno_core::anyhow::Error; -use deno_core::FsModuleLoader; -use deno_core::JsRuntime; -use deno_core::RuntimeOptions; -use std::rc::Rc; - -fn main() -> Result<(), Error> { - let args: Vec<String> = std::env::args().collect(); - if args.len() < 2 { - println!("Usage: target/examples/debug/fs_module_loader <path_to_module>"); - std::process::exit(1); - } - let main_url = &args[1]; - println!("Run {main_url}"); - - let mut js_runtime = JsRuntime::new(RuntimeOptions { - module_loader: Some(Rc::new(FsModuleLoader)), - ..Default::default() - }); - - let runtime = tokio::runtime::Builder::new_current_thread() - .enable_all() - .build()?; - - let main_module = deno_core::resolve_path( - main_url, - &std::env::current_dir().context("Unable to get CWD")?, - )?; - - let future = async move { - let mod_id = js_runtime.load_main_module(&main_module, None).await?; - let result = js_runtime.mod_evaluate(mod_id); - js_runtime.run_event_loop(false).await?; - result.await? - }; - runtime.block_on(future) -} |