提交 95eac608 编写于 作者: G gurv-s 提交者: Ryan Dahl

Make print_file_info async

上级 564222bc
...@@ -51,6 +51,7 @@ use flags::DenoFlags; ...@@ -51,6 +51,7 @@ use flags::DenoFlags;
use flags::DenoSubcommand; use flags::DenoSubcommand;
use futures::lazy; use futures::lazy;
use futures::Future; use futures::Future;
use futures::future;
use log::{LevelFilter, Metadata, Record}; use log::{LevelFilter, Metadata, Record};
use std::env; use std::env;
...@@ -92,53 +93,55 @@ where ...@@ -92,53 +93,55 @@ where
} }
} }
pub fn print_file_info(worker: &Worker, url: &str) { pub fn print_file_info(
let maybe_out = worker: Worker,
state::fetch_module_meta_data_and_maybe_compile(&worker.state, url, "."); url: &str,
if let Err(err) = maybe_out { ) -> impl Future<Item = Worker, Error = ()> {
println!("{}", err); worker::fetch_module_meta_data_and_maybe_compile_async(
return; &worker.state,
} url,
let out = maybe_out.unwrap(); ".",
).and_then(move |out| {
println!("{} {}", ansi::bold("local:".to_string()), &(out.filename)); println!("{} {}", ansi::bold("local:".to_string()), &(out.filename));
println!(
"{} {}",
ansi::bold("type:".to_string()),
msg::enum_name_media_type(out.media_type)
);
if out.maybe_output_code_filename.is_some() {
println!( println!(
"{} {}", "{} {}",
ansi::bold("compiled:".to_string()), ansi::bold("type:".to_string()),
out.maybe_output_code_filename.as_ref().unwrap(), msg::enum_name_media_type(out.media_type)
); );
}
if out.maybe_source_map_filename.is_some() { if out.maybe_output_code_filename.is_some() {
println!( println!(
"{} {}", "{} {}",
ansi::bold("map:".to_string()), ansi::bold("compiled:".to_string()),
out.maybe_source_map_filename.as_ref().unwrap() out.maybe_output_code_filename.as_ref().unwrap(),
); );
} }
if out.maybe_source_map_filename.is_some() {
println!(
"{} {}",
ansi::bold("map:".to_string()),
out.maybe_source_map_filename.as_ref().unwrap()
);
}
let modules = worker.modules.lock().unwrap(); let modules = worker.modules.lock().unwrap();
if let Some(deps) = modules.deps(&out.module_name) { if let Some(deps) = worker.modules.deps(&out.module_name) {
println!("{}{}", ansi::bold("deps:\n".to_string()), deps.name); println!("{}{}", ansi::bold("deps:\n".to_string()), deps.name);
if let Some(ref depsdeps) = deps.deps { if let Some(ref depsdeps) = deps.deps {
for d in depsdeps { for d in depsdeps {
println!("{}", d); println!("{}", d);
}
} }
} else {
println!(
"{} cannot retrieve full dependency graph",
ansi::bold("deps:".to_string()),
);
} }
} else { Ok(worker)
println!( }).map_err(|err| println!("{}", err))
"{} cannot retrieve full dependency graph",
ansi::bold("deps:".to_string()),
);
}
} }
fn create_worker_and_state( fn create_worker_and_state(
...@@ -195,8 +198,11 @@ fn fetch_or_info_command( ...@@ -195,8 +198,11 @@ fn fetch_or_info_command(
.execute_mod_async(&main_url, true) .execute_mod_async(&main_url, true)
.and_then(move |()| { .and_then(move |()| {
if print_info { if print_info {
print_file_info(&worker, &main_module); future::Either::A(print_file_info(worker, &main_module))
} else {
future::Either::B(future::ok(worker))
} }
}).and_then(|worker| {
worker.then(|result| { worker.then(|result| {
js_check(result); js_check(result);
Ok(()) Ok(())
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册