summaryrefslogtreecommitdiff
path: root/cli/main_runtime.rs
blob: f6d20f67eab06324e107dda1c91fe777ba49ca4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.

#![deny(warnings)]

#[macro_use]
extern crate lazy_static;

mod colors;
mod standalone;
mod tokio_util;
mod version;

use deno_core::error::anyhow;
use deno_core::error::AnyError;
use std::env;

pub fn main() {
  #[cfg(windows)]
  colors::enable_ansi(); // For Windows 10

  let args: Vec<String> = env::args().collect();
  if let Err(err) = run(args) {
    eprintln!("{}: {}", colors::red_bold("error"), err.to_string());
    std::process::exit(1);
  }
}

fn run(args: Vec<String>) -> Result<(), AnyError> {
  let (metadata, bundle) = standalone::extract_standalone(args)?
    .ok_or_else(|| anyhow!("This executable is used internally by 'deno compile', it is not meant to be invoked directly."))?;
  tokio_util::run_basic(standalone::run(bundle, metadata))
}