diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2020-08-25 00:52:05 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-24 17:52:05 +0200 |
commit | 111a2fbe3e6b386c2e39d394f95f989a6c1f48a0 (patch) | |
tree | 695db9dacd03c6005c1aa30c12f1707b68de3b13 | |
parent | 2600d5ac090536117109f0b72e2d52f06bf4523a (diff) |
refactor(cli/build.rs): extract ts version (#7127)
-rw-r--r-- | cli/build.rs | 13 | ||||
-rw-r--r-- | cli/dts/README.md | 2 |
2 files changed, 11 insertions, 4 deletions
diff --git a/cli/build.rs b/cli/build.rs index 4c87d15e0..df4211d8b 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -71,8 +71,17 @@ fn create_compiler_snapshot( } fn ts_version() -> String { - // TODO(ry) This should be automatically extracted from typescript.js - "3.9.7".to_string() + std::fs::read_to_string("tsc/00_typescript.js") + .unwrap() + .lines() + .find(|l| l.contains("ts.version = ")) + .expect( + "Failed to find the pattern `ts.version = ` in typescript source code", + ) + .chars() + .skip_while(|c| !char::is_numeric(*c)) + .take_while(|c| *c != '"') + .collect::<String>() } fn main() { diff --git a/cli/dts/README.md b/cli/dts/README.md index bb68a0c62..bfa022109 100644 --- a/cli/dts/README.md +++ b/cli/dts/README.md @@ -7,8 +7,6 @@ It works like this currently: 1. Checkout typescript repo in a seperate directory. 2. Copy typescript.js into Deno repo 3. Copy d.ts files into dts directory -4. Update `ts_version()` in `cli/build.rs` - https://github.com/denoland/deno/blob/452693256ce7b607fa0b9454b22c57748f616742/cli/build.rs#L73-L76 So that might look something like this: |