Skip to content

Commit

Permalink
cli: refactor deno_dir to use Url instead of String
Browse files Browse the repository at this point in the history
  • Loading branch information
bartlomieju authored and piscisaureus committed Jul 8, 2019
1 parent 9b1997b commit 72d9045
Show file tree
Hide file tree
Showing 8 changed files with 345 additions and 477 deletions.
8 changes: 7 additions & 1 deletion cli/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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| {
Expand Down
Loading

0 comments on commit 72d9045

Please sign in to comment.