diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/main.rs | 8 | ||||
-rw-r--r-- | cli/ops/os.rs | 1 | ||||
-rw-r--r-- | cli/version.rs | 11 |
3 files changed, 19 insertions, 1 deletions
diff --git a/cli/main.rs b/cli/main.rs index 682d1055f..948f8544e 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -398,6 +398,12 @@ fn run_script(flags: DenoFlags, argv: Vec<String>) { } } +fn version_command() { + println!("deno: {}", version::DENO); + println!("v8: {}", version::v8()); + println!("typescript: {}", version::typescript()); +} + fn main() { #[cfg(windows)] ansi_term::enable_ansi_support().ok(); // For Windows 10 @@ -425,7 +431,7 @@ fn main() { DenoSubcommand::Repl => run_repl(flags, argv), DenoSubcommand::Run => run_script(flags, argv), DenoSubcommand::Types => types_command(), - DenoSubcommand::Version => run_repl(flags, argv), + DenoSubcommand::Version => version_command(), DenoSubcommand::Xeval => xeval_command(flags, argv), } } diff --git a/cli/ops/os.rs b/cli/ops/os.rs index afb87539f..d644d893b 100644 --- a/cli/ops/os.rs +++ b/cli/ops/os.rs @@ -28,6 +28,7 @@ pub fn op_start( "versionFlag": state.flags.version, "v8Version": version::v8(), "denoVersion": version::DENO, + "tsVersion": version::typescript(), "noColor": !ansi::use_color(), "xevalDelim": state.flags.xeval_delim.clone(), }))) diff --git a/cli/version.rs b/cli/version.rs index 4b9509af9..2c98a96d4 100644 --- a/cli/version.rs +++ b/cli/version.rs @@ -1,6 +1,17 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +use serde_json; pub const DENO: &str = env!("CARGO_PKG_VERSION"); pub fn v8() -> &'static str { deno::v8_version() } + +pub fn typescript() -> String { + // TODO: By using include_str! we are including the package.json into + // the deno binary using serde to decode it at runtime. This is suboptimal + // in space and time. We need to extract the TypeScript version at compile + // time instead. This will be easier after #2608. + let data = include_str!("../node_modules/typescript/package.json"); + let pkg: serde_json::Value = serde_json::from_str(data).unwrap(); + pkg["version"].as_str().unwrap().to_string() +} |