diff options
author | Luca Casonato <lucacasonato@yahoo.com> | 2021-01-08 03:08:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-08 03:08:51 +0100 |
commit | a44349dfdfecacdd4ccd343a984b05abb728bf88 (patch) | |
tree | 690b5047cc54d62ce27013ebb199e9bdc7de0937 /cli/main_runtime.rs | |
parent | e61e81eb57351782862aa50775ce4348f10b1856 (diff) |
feat: denort binary (#9041)
This commit adds new binary target called "denort".
It is a "lite" version of "deno" binary that can only execute
code embedded inside the binary itself.
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Diffstat (limited to 'cli/main_runtime.rs')
-rw-r--r-- | cli/main_runtime.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cli/main_runtime.rs b/cli/main_runtime.rs new file mode 100644 index 000000000..12cb4329d --- /dev/null +++ b/cli/main_runtime.rs @@ -0,0 +1,32 @@ +// Copyright 2018-2020 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)) +} |