Skip to content

Commit

Permalink
Add output for --json flag
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisChambers committed Jul 17, 2020
1 parent cdef73a commit a8fa6c3
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ use crate::permissions::Permissions;
use crate::worker::MainWorker;
use deno_core::v8_set_flags;
use deno_core::ErrBox;
use deno_core::EsIsolate;
use deno_core::ModuleSpecifier;
use flags::DenoSubcommand;
use flags::Flags;
Expand All @@ -93,6 +92,7 @@ use futures::Future;
use log::Level;
use log::Metadata;
use log::Record;
use serde::Serialize;
use state::exit_unstable;
use std::env;
use std::io::Read;
Expand Down Expand Up @@ -183,6 +183,7 @@ fn print_cache_info(state: &GlobalState, json: bool) -> Result<(), ErrBox> {
///
/// Constructed from a `ModuleGraph` and `ModuleSpecifier` that
/// acts as the root of the tree.
#[derive(Serialize)]
struct FileInfoDepTree {
name: String,
size: usize,
Expand Down Expand Up @@ -273,16 +274,13 @@ async fn print_file_info(
let file_info = FileInfoDepTree::new(&module_graph, &module_specifier);

if json {
let es_state_rc = EsIsolate::state(&worker.isolate);
let es_state = es_state_rc.borrow();
let deps = es_state.modules.deps(&module_specifier);

let output = json!({
"local": local,
"fileType": file_type,
"compiled": compiled,
"map": map,
"deps": deps.map(|x| x.to_json())
"deps": file_info
});

write_json_to_stdout(&output)
Expand Down

0 comments on commit a8fa6c3

Please sign in to comment.