diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2019-06-25 22:14:36 +0200 |
---|---|---|
committer | Bert Belder <bertbelder@gmail.com> | 2019-07-08 13:07:32 +0200 |
commit | 72d9045528ad69ec32d7de9707cea65fab9f405e (patch) | |
tree | 7492b1109462be8512269a2a7041c02f4038e56e /cli/compiler.rs | |
parent | 9b1997b8b6f82e17e42c43aae3621e2b932f5843 (diff) |
cli: refactor deno_dir to use Url instead of String
Diffstat (limited to 'cli/compiler.rs')
-rw-r--r-- | cli/compiler.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cli/compiler.rs b/cli/compiler.rs index c7adbe390..c827c3ca1 100644 --- a/cli/compiler.rs +++ b/cli/compiler.rs @@ -9,6 +9,7 @@ use crate::state::*; use crate::tokio_util; use crate::worker::Worker; use deno::Buf; +use deno::ModuleSpecifier; use futures::Future; use futures::Stream; use std::path::PathBuf; @@ -17,6 +18,7 @@ use std::sync::atomic::Ordering; // This corresponds to JS ModuleMetaData. // TODO Rename one or the other so they correspond. +// TODO(bartlomieju): change `*_name` to `*_url` and use Url type #[derive(Debug, Clone)] pub struct ModuleMetaData { pub module_name: String, @@ -203,6 +205,8 @@ pub fn compile_async( .and_then(move |maybe_msg: Option<Buf>| { debug!("Received message from worker"); + // TODO: here TS compiler emitted the files to disc and we should signal ModuleMetaData + // cache that source code is available if let Some(msg) = maybe_msg { let json_str = std::str::from_utf8(&msg).unwrap(); debug!("Message: {}", json_str); @@ -213,8 +217,10 @@ pub fn compile_async( Ok(()) }).and_then(move |_| { + let module_specifier = ModuleSpecifier::resolve_url(&module_name) + .expect("Should be valid module specifier"); state.dir.fetch_module_meta_data_async( - &module_name, + &module_specifier, true, true, ).map_err(|e| { |