summaryrefslogtreecommitdiff
path: root/cli/version.rs
diff options
context:
space:
mode:
authorYoshiya Hinosawa <stibium121@gmail.com>2019-09-04 11:12:21 +0900
committerRyan Dahl <ry@tinyclouds.org>2019-09-03 22:12:21 -0400
commit249db0f7d91d5e895906078f92b7d31c76b96121 (patch)
tree3a9dc5f04ce1bd01b4762f06ff24dd6127f26ae5 /cli/version.rs
parente9908453df970b1cdf90483892bc9e794382fccc (diff)
Handle typescript version in rust (#2855)
Diffstat (limited to 'cli/version.rs')
-rw-r--r--cli/version.rs11
1 files changed, 11 insertions, 0 deletions
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()
+}