2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-01-06 11:38:56 -05:00
|
|
|
#![deny(warnings)]
|
|
|
|
|
2019-09-16 21:05:14 -04:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate log;
|
|
|
|
extern crate futures;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_json;
|
|
|
|
extern crate clap;
|
2020-01-05 11:56:18 -05:00
|
|
|
extern crate deno_core;
|
2019-09-16 21:05:14 -04:00
|
|
|
extern crate indexmap;
|
|
|
|
#[cfg(unix)]
|
|
|
|
extern crate nix;
|
|
|
|
extern crate rand;
|
|
|
|
extern crate serde;
|
|
|
|
extern crate serde_derive;
|
2019-11-04 10:38:52 -05:00
|
|
|
extern crate tokio;
|
2019-09-16 21:05:14 -04:00
|
|
|
extern crate url;
|
|
|
|
|
2019-11-03 10:39:27 -05:00
|
|
|
mod checksum;
|
2019-09-16 21:05:14 -04:00
|
|
|
pub mod colors;
|
|
|
|
pub mod compilers;
|
|
|
|
pub mod deno_dir;
|
|
|
|
pub mod deno_error;
|
|
|
|
pub mod diagnostics;
|
|
|
|
mod disk_cache;
|
|
|
|
mod file_fetcher;
|
|
|
|
pub mod flags;
|
|
|
|
pub mod fmt_errors;
|
|
|
|
mod fs;
|
2019-11-04 10:38:52 -05:00
|
|
|
mod global_state;
|
2019-09-16 21:05:14 -04:00
|
|
|
mod global_timer;
|
|
|
|
mod http_util;
|
|
|
|
mod import_map;
|
2019-10-04 20:28:51 -04:00
|
|
|
mod js;
|
2019-11-03 10:39:27 -05:00
|
|
|
mod lockfile;
|
2019-11-04 10:38:52 -05:00
|
|
|
mod metrics;
|
2019-09-16 21:05:14 -04:00
|
|
|
pub mod msg;
|
|
|
|
pub mod ops;
|
|
|
|
pub mod permissions;
|
|
|
|
mod progress;
|
|
|
|
mod repl;
|
|
|
|
pub mod resolve_addr;
|
|
|
|
mod shell;
|
|
|
|
mod signal;
|
|
|
|
pub mod source_maps;
|
|
|
|
mod startup_data;
|
|
|
|
pub mod state;
|
2019-09-19 14:48:05 -04:00
|
|
|
pub mod test_util;
|
2019-09-16 21:05:14 -04:00
|
|
|
mod tokio_util;
|
|
|
|
pub mod version;
|
2020-01-21 03:49:47 -05:00
|
|
|
mod web_worker;
|
2019-09-16 21:05:14 -04:00
|
|
|
pub mod worker;
|
|
|
|
|
2019-09-25 10:46:58 -04:00
|
|
|
use crate::deno_error::js_check;
|
2019-11-26 23:25:14 -05:00
|
|
|
use crate::deno_error::{print_err_and_exit, print_msg_and_exit};
|
2019-11-04 10:38:52 -05:00
|
|
|
use crate::global_state::ThreadSafeGlobalState;
|
2019-11-14 12:10:25 -05:00
|
|
|
use crate::ops::io::get_stdio;
|
2019-09-16 21:05:14 -04:00
|
|
|
use crate::progress::Progress;
|
|
|
|
use crate::state::ThreadSafeState;
|
2020-01-21 11:50:06 -05:00
|
|
|
use crate::worker::MainWorker;
|
2020-01-05 11:56:18 -05:00
|
|
|
use deno_core::v8_set_flags;
|
|
|
|
use deno_core::ErrBox;
|
|
|
|
use deno_core::ModuleSpecifier;
|
2019-09-16 21:05:14 -04:00
|
|
|
use flags::DenoFlags;
|
|
|
|
use flags::DenoSubcommand;
|
|
|
|
use log::Level;
|
|
|
|
use log::Metadata;
|
|
|
|
use log::Record;
|
|
|
|
use std::env;
|
|
|
|
|
|
|
|
static LOGGER: Logger = Logger;
|
|
|
|
|
|
|
|
struct Logger;
|
|
|
|
|
|
|
|
impl log::Log for Logger {
|
|
|
|
fn enabled(&self, metadata: &Metadata) -> bool {
|
|
|
|
metadata.level() <= log::max_level()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn log(&self, record: &Record) {
|
|
|
|
if self.enabled(record.metadata()) {
|
|
|
|
let mut target = record.target().to_string();
|
|
|
|
|
|
|
|
if let Some(line_no) = record.line() {
|
|
|
|
target.push_str(":");
|
|
|
|
target.push_str(&line_no.to_string());
|
|
|
|
}
|
|
|
|
|
|
|
|
println!("{} RS - {} - {}", record.level(), target, record.args());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn flush(&self) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn create_worker_and_state(
|
|
|
|
flags: DenoFlags,
|
2020-01-21 11:50:06 -05:00
|
|
|
) -> (MainWorker, ThreadSafeGlobalState) {
|
2019-09-16 21:05:14 -04:00
|
|
|
use crate::shell::Shell;
|
|
|
|
use std::sync::Arc;
|
|
|
|
use std::sync::Mutex;
|
2019-11-04 10:38:52 -05:00
|
|
|
|
2019-09-16 21:05:14 -04:00
|
|
|
let shell = Arc::new(Mutex::new(Shell::new()));
|
2019-11-04 10:38:52 -05:00
|
|
|
|
2019-09-16 21:05:14 -04:00
|
|
|
let progress = Progress::new();
|
|
|
|
progress.set_callback(move |_done, _completed, _total, status, msg| {
|
|
|
|
if !status.is_empty() {
|
|
|
|
let mut s = shell.lock().unwrap();
|
|
|
|
s.status(status, msg).expect("shell problem");
|
|
|
|
}
|
|
|
|
});
|
2019-11-04 10:38:52 -05:00
|
|
|
|
2019-12-03 17:23:10 -05:00
|
|
|
let global_state = ThreadSafeGlobalState::new(flags, progress)
|
2019-09-25 10:46:58 -04:00
|
|
|
.map_err(deno_error::print_err_and_exit)
|
2019-09-16 21:05:14 -04:00
|
|
|
.unwrap();
|
|
|
|
|
2019-11-09 15:07:14 -05:00
|
|
|
let (int, ext) = ThreadSafeState::create_channels();
|
2019-11-04 10:38:52 -05:00
|
|
|
let state = ThreadSafeState::new(
|
|
|
|
global_state.clone(),
|
2019-11-24 10:42:30 -05:00
|
|
|
None,
|
2019-11-04 10:38:52 -05:00
|
|
|
global_state.main_module.clone(),
|
2019-11-09 15:07:14 -05:00
|
|
|
int,
|
2019-11-04 10:38:52 -05:00
|
|
|
)
|
|
|
|
.map_err(deno_error::print_err_and_exit)
|
|
|
|
.unwrap();
|
|
|
|
|
2019-11-14 12:10:25 -05:00
|
|
|
let state_ = state.clone();
|
|
|
|
{
|
|
|
|
let mut resource_table = state_.lock_resource_table();
|
|
|
|
let (stdin, stdout, stderr) = get_stdio();
|
|
|
|
resource_table.add("stdin", Box::new(stdin));
|
|
|
|
resource_table.add("stdout", Box::new(stdout));
|
|
|
|
resource_table.add("stderr", Box::new(stderr));
|
|
|
|
}
|
|
|
|
|
2020-01-21 11:50:06 -05:00
|
|
|
let worker = MainWorker::new(
|
2019-11-09 15:07:14 -05:00
|
|
|
"main".to_string(),
|
|
|
|
startup_data::deno_isolate_init(),
|
|
|
|
state,
|
|
|
|
ext,
|
|
|
|
);
|
2019-11-04 10:38:52 -05:00
|
|
|
|
|
|
|
(worker, global_state)
|
2019-09-16 21:05:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn types_command() {
|
2020-01-22 14:18:01 -05:00
|
|
|
println!("{}", crate::js::DENO_RUNTIME);
|
2019-09-16 21:05:14 -04:00
|
|
|
}
|
|
|
|
|
2020-01-21 11:50:06 -05:00
|
|
|
fn print_cache_info(worker: MainWorker) {
|
2019-11-04 10:38:52 -05:00
|
|
|
let state = &worker.state.global_state;
|
2019-09-16 21:05:14 -04:00
|
|
|
|
|
|
|
println!(
|
|
|
|
"{} {:?}",
|
|
|
|
colors::bold("DENO_DIR location:".to_string()),
|
|
|
|
state.dir.root
|
|
|
|
);
|
|
|
|
println!(
|
|
|
|
"{} {:?}",
|
|
|
|
colors::bold("Remote modules cache:".to_string()),
|
|
|
|
state.dir.deps_cache.location
|
|
|
|
);
|
|
|
|
println!(
|
|
|
|
"{} {:?}",
|
|
|
|
colors::bold("TypeScript compiler cache:".to_string()),
|
|
|
|
state.dir.gen_cache.location
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-01-21 11:50:06 -05:00
|
|
|
async fn print_file_info(
|
|
|
|
worker: MainWorker,
|
|
|
|
module_specifier: ModuleSpecifier,
|
|
|
|
) {
|
2019-11-16 23:25:12 -05:00
|
|
|
let global_state_ = &worker.state.global_state;
|
2019-09-16 21:05:14 -04:00
|
|
|
|
2019-11-16 23:25:12 -05:00
|
|
|
let maybe_source_file = global_state_
|
2019-09-16 21:05:14 -04:00
|
|
|
.file_fetcher
|
2019-11-25 09:33:23 -05:00
|
|
|
.fetch_source_file_async(&module_specifier, None)
|
2019-11-16 23:25:12 -05:00
|
|
|
.await;
|
|
|
|
if let Err(err) = maybe_source_file {
|
|
|
|
println!("{}", err);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
let out = maybe_source_file.unwrap();
|
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
colors::bold("local:".to_string()),
|
|
|
|
out.filename.to_str().unwrap()
|
|
|
|
);
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
colors::bold("type:".to_string()),
|
|
|
|
msg::enum_name_media_type(out.media_type)
|
|
|
|
);
|
|
|
|
|
|
|
|
let maybe_compiled = global_state_
|
|
|
|
.clone()
|
2019-11-25 09:33:23 -05:00
|
|
|
.fetch_compiled_module(&module_specifier, None)
|
2019-11-16 23:25:12 -05:00
|
|
|
.await;
|
|
|
|
if let Err(e) = maybe_compiled {
|
|
|
|
debug!("compiler error exiting!");
|
|
|
|
eprintln!("\n{}", e.to_string());
|
|
|
|
std::process::exit(1);
|
|
|
|
}
|
|
|
|
let compiled = maybe_compiled.unwrap();
|
|
|
|
if out.media_type == msg::MediaType::TypeScript
|
|
|
|
|| (out.media_type == msg::MediaType::JavaScript
|
|
|
|
&& global_state_.ts_compiler.compile_js)
|
|
|
|
{
|
|
|
|
let compiled_source_file = global_state_
|
|
|
|
.ts_compiler
|
|
|
|
.get_compiled_source_file(&out.url)
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
colors::bold("compiled:".to_string()),
|
|
|
|
compiled_source_file.filename.to_str().unwrap(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if let Ok(source_map) = global_state_
|
|
|
|
.clone()
|
|
|
|
.ts_compiler
|
|
|
|
.get_source_map_file(&module_specifier)
|
|
|
|
{
|
|
|
|
println!(
|
|
|
|
"{} {}",
|
|
|
|
colors::bold("map:".to_string()),
|
|
|
|
source_map.filename.to_str().unwrap()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-01-08 09:06:04 -05:00
|
|
|
let isolate = worker.isolate.try_lock().unwrap();
|
|
|
|
if let Some(deps) = isolate.modules.deps(&compiled.name) {
|
2019-11-16 23:25:12 -05:00
|
|
|
println!("{}{}", colors::bold("deps:\n".to_string()), deps.name);
|
|
|
|
if let Some(ref depsdeps) = deps.deps {
|
|
|
|
for d in depsdeps {
|
|
|
|
println!("{}", d);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
println!(
|
|
|
|
"{} cannot retrieve full dependency graph",
|
|
|
|
colors::bold("deps:".to_string()),
|
|
|
|
);
|
|
|
|
}
|
2019-09-16 21:05:14 -04:00
|
|
|
}
|
|
|
|
|
2019-11-26 11:06:32 -05:00
|
|
|
fn info_command(flags: DenoFlags) {
|
|
|
|
let argv_len = flags.argv.len();
|
|
|
|
let (mut worker, state) = create_worker_and_state(flags);
|
2019-09-16 21:05:14 -04:00
|
|
|
|
|
|
|
// If it was just "deno info" print location of caches and exit
|
2019-11-26 11:06:32 -05:00
|
|
|
if argv_len == 1 {
|
2019-09-16 21:05:14 -04:00
|
|
|
return print_cache_info(worker);
|
|
|
|
}
|
|
|
|
|
2019-11-04 10:38:52 -05:00
|
|
|
let main_module = state.main_module.as_ref().unwrap().clone();
|
2019-09-16 21:05:14 -04:00
|
|
|
|
2019-11-16 19:17:47 -05:00
|
|
|
// Setup runtime.
|
2020-01-21 09:53:29 -05:00
|
|
|
js_check(worker.execute("bootstrapMainRuntime()"));
|
2019-11-16 19:17:47 -05:00
|
|
|
debug!("main_module {}", main_module);
|
|
|
|
|
2019-11-16 23:25:12 -05:00
|
|
|
let main_future = async move {
|
|
|
|
let main_result = worker.execute_mod_async(&main_module, None, true).await;
|
|
|
|
if let Err(e) = main_result {
|
|
|
|
print_err_and_exit(e);
|
|
|
|
}
|
|
|
|
print_file_info(worker.clone(), main_module.clone()).await;
|
|
|
|
let result = worker.await;
|
|
|
|
js_check(result);
|
|
|
|
};
|
2019-11-16 19:17:47 -05:00
|
|
|
|
2019-09-16 21:05:14 -04:00
|
|
|
tokio_util::run(main_future);
|
|
|
|
}
|
|
|
|
|
2019-11-26 11:06:32 -05:00
|
|
|
fn fetch_command(flags: DenoFlags) {
|
|
|
|
let (mut worker, state) = create_worker_and_state(flags);
|
2019-09-16 21:05:14 -04:00
|
|
|
|
2019-11-04 10:38:52 -05:00
|
|
|
let main_module = state.main_module.as_ref().unwrap().clone();
|
2019-09-16 21:05:14 -04:00
|
|
|
|
2019-11-16 19:17:47 -05:00
|
|
|
// Setup runtime.
|
2020-01-21 09:53:29 -05:00
|
|
|
js_check(worker.execute("bootstrapMainRuntime()"));
|
2019-11-16 19:17:47 -05:00
|
|
|
debug!("main_module {}", main_module);
|
|
|
|
|
2019-11-16 23:25:12 -05:00
|
|
|
let main_future = async move {
|
|
|
|
let result = worker.execute_mod_async(&main_module, None, true).await;
|
|
|
|
js_check(result);
|
|
|
|
};
|
2019-11-16 19:17:47 -05:00
|
|
|
|
2019-09-16 21:05:14 -04:00
|
|
|
tokio_util::run(main_future);
|
|
|
|
}
|
|
|
|
|
2019-11-26 11:06:32 -05:00
|
|
|
fn eval_command(flags: DenoFlags) {
|
2019-12-03 17:23:10 -05:00
|
|
|
let ts_source = flags.argv[1].clone();
|
|
|
|
let (mut worker, _state) = create_worker_and_state(flags);
|
2019-10-19 17:19:19 -04:00
|
|
|
// Force TypeScript compile.
|
|
|
|
let main_module =
|
|
|
|
ModuleSpecifier::resolve_url_or_path("./__$deno$eval.ts").unwrap();
|
2019-09-16 21:05:14 -04:00
|
|
|
|
2020-01-21 09:53:29 -05:00
|
|
|
js_check(worker.execute("bootstrapMainRuntime()"));
|
2019-11-16 19:17:47 -05:00
|
|
|
debug!("main_module {}", &main_module);
|
2019-10-19 17:19:19 -04:00
|
|
|
|
2019-11-16 23:25:12 -05:00
|
|
|
let main_future = async move {
|
|
|
|
let exec_result = worker
|
|
|
|
.execute_mod_async(&main_module, Some(ts_source), false)
|
|
|
|
.await;
|
|
|
|
if let Err(e) = exec_result {
|
|
|
|
print_err_and_exit(e);
|
|
|
|
}
|
|
|
|
js_check(worker.execute("window.dispatchEvent(new Event('load'))"));
|
|
|
|
let mut worker_ = worker.clone();
|
|
|
|
let result = worker.await;
|
|
|
|
js_check(result);
|
|
|
|
js_check(worker_.execute("window.dispatchEvent(new Event('unload'))"));
|
|
|
|
};
|
2019-11-16 19:17:47 -05:00
|
|
|
|
2019-09-16 21:05:14 -04:00
|
|
|
tokio_util::run(main_future);
|
|
|
|
}
|
|
|
|
|
2019-11-26 11:06:32 -05:00
|
|
|
fn bundle_command(flags: DenoFlags) {
|
|
|
|
let out_file = flags.bundle_output.clone();
|
|
|
|
let (worker, state) = create_worker_and_state(flags);
|
2019-11-04 10:38:52 -05:00
|
|
|
let main_module = state.main_module.as_ref().unwrap().clone();
|
2019-11-26 11:06:32 -05:00
|
|
|
|
2019-09-16 21:05:14 -04:00
|
|
|
debug!(">>>>> bundle_async START");
|
2019-10-14 17:46:27 -04:00
|
|
|
// NOTE: we need to poll `worker` otherwise TS compiler worker won't run properly
|
2019-11-16 23:25:12 -05:00
|
|
|
let main_future = async move {
|
|
|
|
let result = worker.await;
|
2019-11-16 19:17:47 -05:00
|
|
|
js_check(result);
|
2019-11-16 23:25:12 -05:00
|
|
|
let bundle_result = state
|
2019-11-16 19:17:47 -05:00
|
|
|
.ts_compiler
|
|
|
|
.bundle_async(state.clone(), main_module.to_string(), out_file)
|
2019-11-16 23:25:12 -05:00
|
|
|
.await;
|
|
|
|
if let Err(err) = bundle_result {
|
|
|
|
debug!("diagnostics returned, exiting!");
|
|
|
|
eprintln!("");
|
|
|
|
print_err_and_exit(err);
|
|
|
|
}
|
|
|
|
debug!(">>>>> bundle_async END");
|
|
|
|
};
|
2019-10-14 17:46:27 -04:00
|
|
|
tokio_util::run(main_future);
|
2019-09-16 21:05:14 -04:00
|
|
|
}
|
|
|
|
|
2019-11-26 11:06:32 -05:00
|
|
|
fn run_repl(flags: DenoFlags) {
|
|
|
|
let (mut worker, _state) = create_worker_and_state(flags);
|
2020-01-21 09:53:29 -05:00
|
|
|
js_check(worker.execute("bootstrapMainRuntime()"));
|
2019-11-16 23:25:12 -05:00
|
|
|
let main_future = async move {
|
2020-01-21 03:49:47 -05:00
|
|
|
loop {
|
|
|
|
let result = worker.clone().await;
|
|
|
|
if let Err(err) = result {
|
|
|
|
eprintln!("{}", err.to_string());
|
|
|
|
worker.clear_exception();
|
|
|
|
}
|
|
|
|
}
|
2019-11-16 23:25:12 -05:00
|
|
|
};
|
2019-09-16 21:05:14 -04:00
|
|
|
tokio_util::run(main_future);
|
|
|
|
}
|
|
|
|
|
2019-11-26 11:06:32 -05:00
|
|
|
fn run_script(flags: DenoFlags) {
|
2019-09-16 21:05:14 -04:00
|
|
|
let use_current_thread = flags.current_thread;
|
2019-11-26 11:06:32 -05:00
|
|
|
let (mut worker, state) = create_worker_and_state(flags);
|
2019-09-16 21:05:14 -04:00
|
|
|
|
2019-11-26 23:25:14 -05:00
|
|
|
let maybe_main_module = state.main_module.as_ref();
|
|
|
|
if maybe_main_module.is_none() {
|
|
|
|
print_msg_and_exit("Please provide a name to the main script to run.");
|
|
|
|
}
|
|
|
|
let main_module = maybe_main_module.unwrap().clone();
|
2019-09-16 21:05:14 -04:00
|
|
|
// Normal situation of executing a module.
|
|
|
|
|
2019-11-16 19:17:47 -05:00
|
|
|
// Setup runtime.
|
2020-01-21 09:53:29 -05:00
|
|
|
js_check(worker.execute("bootstrapMainRuntime()"));
|
2019-11-16 19:17:47 -05:00
|
|
|
debug!("main_module {}", main_module);
|
2019-10-02 11:32:51 -04:00
|
|
|
|
2019-11-16 19:17:47 -05:00
|
|
|
let mut worker_ = worker.clone();
|
|
|
|
|
2019-11-16 23:25:12 -05:00
|
|
|
let main_future = async move {
|
|
|
|
let mod_result = worker.execute_mod_async(&main_module, None, false).await;
|
|
|
|
if let Err(err) = mod_result {
|
|
|
|
print_err_and_exit(err);
|
|
|
|
}
|
|
|
|
if state.flags.lock_write {
|
|
|
|
if let Some(ref lockfile) = state.lockfile {
|
|
|
|
let g = lockfile.lock().unwrap();
|
|
|
|
if let Err(e) = g.write() {
|
|
|
|
print_err_and_exit(ErrBox::from(e));
|
2019-11-03 10:39:27 -05:00
|
|
|
}
|
2019-11-16 23:25:12 -05:00
|
|
|
} else {
|
|
|
|
eprintln!("--lock flag must be specified when using --lock-write");
|
|
|
|
std::process::exit(11);
|
2019-11-16 19:17:47 -05:00
|
|
|
}
|
2019-11-16 23:25:12 -05:00
|
|
|
}
|
|
|
|
js_check(worker.execute("window.dispatchEvent(new Event('load'))"));
|
|
|
|
let result = worker.await;
|
|
|
|
js_check(result);
|
|
|
|
js_check(worker_.execute("window.dispatchEvent(new Event('unload'))"));
|
|
|
|
};
|
2019-09-16 21:05:14 -04:00
|
|
|
|
|
|
|
if use_current_thread {
|
|
|
|
tokio_util::run_on_current_thread(main_future);
|
|
|
|
} else {
|
|
|
|
tokio_util::run(main_future);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn main() {
|
|
|
|
#[cfg(windows)]
|
|
|
|
ansi_term::enable_ansi_support().ok(); // For Windows 10
|
|
|
|
|
|
|
|
log::set_logger(&LOGGER).unwrap();
|
|
|
|
let args: Vec<String> = env::args().collect();
|
2019-11-26 11:06:32 -05:00
|
|
|
let flags = flags::flags_from_vec(args);
|
2019-09-16 21:05:14 -04:00
|
|
|
|
|
|
|
if let Some(ref v8_flags) = flags.v8_flags {
|
2019-11-26 11:06:32 -05:00
|
|
|
let mut v8_flags_ = v8_flags.clone();
|
|
|
|
v8_flags_.insert(0, "UNUSED_BUT_NECESSARY_ARG0".to_string());
|
|
|
|
v8_set_flags(v8_flags_);
|
2019-09-16 21:05:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
let log_level = match flags.log_level {
|
|
|
|
Some(level) => level,
|
|
|
|
None => Level::Warn,
|
|
|
|
};
|
|
|
|
log::set_max_level(log_level.to_level_filter());
|
|
|
|
|
2019-11-26 11:06:32 -05:00
|
|
|
match flags.subcommand {
|
|
|
|
DenoSubcommand::Bundle => bundle_command(flags),
|
2019-09-16 21:05:14 -04:00
|
|
|
DenoSubcommand::Completions => {}
|
2019-11-26 11:06:32 -05:00
|
|
|
DenoSubcommand::Eval => eval_command(flags),
|
|
|
|
DenoSubcommand::Fetch => fetch_command(flags),
|
|
|
|
DenoSubcommand::Info => info_command(flags),
|
|
|
|
DenoSubcommand::Repl => run_repl(flags),
|
|
|
|
DenoSubcommand::Run => run_script(flags),
|
2019-09-16 21:05:14 -04:00
|
|
|
DenoSubcommand::Types => types_command(),
|
2019-11-26 11:06:32 -05:00
|
|
|
_ => panic!("bad subcommand"),
|
2019-09-16 21:05:14 -04:00
|
|
|
}
|
|
|
|
}
|