diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/deno.ts | 1 | ||||
-rw-r--r-- | js/main.ts | 10 | ||||
-rw-r--r-- | js/unit_tests.ts | 1 | ||||
-rw-r--r-- | js/version.ts | 23 | ||||
-rw-r--r-- | js/version_test.ts | 8 |
5 files changed, 39 insertions, 4 deletions
diff --git a/js/deno.ts b/js/deno.ts index 490494cc6..66d7d796c 100644 --- a/js/deno.ts +++ b/js/deno.ts @@ -58,6 +58,7 @@ export { metrics, Metrics } from "./metrics"; export { resources } from "./resources"; export { run, RunOptions, Process, ProcessStatus } from "./process"; export { inspect } from "./console"; +export { version } from "./version"; export const args: string[] = []; // TODO Don't expose Console nor stringifyArgs. diff --git a/js/main.ts b/js/main.ts index 1116a1165..a5aae51a1 100644 --- a/js/main.ts +++ b/js/main.ts @@ -9,6 +9,7 @@ import * as os from "./os"; import { libdeno } from "./libdeno"; import { args } from "./deno"; import { replLoop } from "./repl"; +import { setVersions } from "./version"; // builtin modules import * as deno from "./deno"; @@ -24,12 +25,13 @@ export default function denoMain() { libdeno.builtinModules["deno"] = deno; Object.freeze(libdeno.builtinModules); + setVersions(startResMsg.denoVersion()!, startResMsg.v8Version()!); + // handle `--version` if (startResMsg.versionFlag()) { - console.log("deno:", startResMsg.denoVersion()); - console.log("v8:", startResMsg.v8Version()); - // TODO figure out a way to restore functionality - // console.log("typescript:", version); + console.log("deno:", deno.version.deno); + console.log("v8:", deno.version.v8); + console.log("typescript:", deno.version.typescript); os.exit(0); } diff --git a/js/unit_tests.ts b/js/unit_tests.ts index a5fc836c5..c8479145b 100644 --- a/js/unit_tests.ts +++ b/js/unit_tests.ts @@ -44,6 +44,7 @@ import "./url_test.ts"; import "./url_search_params_test.ts"; import "./write_file_test.ts"; import "./performance_test.ts"; +import "./version_test.ts"; import "../website/app_test.js"; diff --git a/js/version.ts b/js/version.ts new file mode 100644 index 000000000..805e565a0 --- /dev/null +++ b/js/version.ts @@ -0,0 +1,23 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +interface Version { + deno: string; + v8: string; + typescript: string; +} + +export const version: Version = { + deno: "", + v8: "", + typescript: "TS_VERSION" // This string will be replaced by rollup +}; + +/** + * Sets the deno and v8 versions and freezes the version object. + * @internal + */ +export function setVersions(denoVersion: string, v8Version: string): void { + version.deno = denoVersion; + version.v8 = v8Version; + + Object.freeze(version); +} diff --git a/js/version_test.ts b/js/version_test.ts new file mode 100644 index 000000000..d3d1bc3df --- /dev/null +++ b/js/version_test.ts @@ -0,0 +1,8 @@ +import { test, assert } from "./test_util.ts"; + +test(function version() { + const pattern = /^\d+\.\d+\.\d+$/; + assert(pattern.test(Deno.version.deno)); + assert(pattern.test(Deno.version.v8)); + assert(pattern.test(Deno.version.typescript)); +}); |