diff options
author | Kevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com> | 2019-03-06 13:54:58 -0800 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2019-03-06 16:54:58 -0500 |
commit | de1a10e5f7afe793a66b2349642ea135fc066104 (patch) | |
tree | 3d91d82a62808f744fc189705110a50d7d8d478e /js | |
parent | 91364cabae8687e7620edac406b43cb40cb55878 (diff) |
Reorganize version and platform into Deno.build and Deno.version (#1879)
Diffstat (limited to 'js')
-rw-r--r-- | js/build.ts | 27 | ||||
-rw-r--r-- | js/build_test.ts (renamed from js/platform_test.ts) | 10 | ||||
-rw-r--r-- | js/chmod_test.ts | 2 | ||||
-rw-r--r-- | js/deno.ts | 2 | ||||
-rw-r--r-- | js/dir_test.ts | 4 | ||||
-rw-r--r-- | js/platform.ts | 18 | ||||
-rw-r--r-- | js/process_test.ts | 2 | ||||
-rw-r--r-- | js/read_link_test.ts | 4 | ||||
-rw-r--r-- | js/unit_tests.ts | 2 | ||||
-rw-r--r-- | js/version.ts | 5 | ||||
-rw-r--r-- | js/version_test.ts | 4 | ||||
-rw-r--r-- | js/write_file_test.ts | 4 |
12 files changed, 46 insertions, 38 deletions
diff --git a/js/build.ts b/js/build.ts new file mode 100644 index 000000000..636f9a082 --- /dev/null +++ b/js/build.ts @@ -0,0 +1,27 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. + +// Do not add unsupported platforms. +/** Build related information */ +export interface BuildInfo { + /** The operating system CPU architecture. */ + arch: "x64"; + + /** The operating system platform. */ + os: "mac" | "win" | "linux"; + + /** The GN build arguments */ + gnArgs: string; +} + +// 'build' is injected by rollup.config.js at compile time. +export const build: BuildInfo = { + // tslint:disable:no-any + // These string will be replaced by rollup + arch: `ROLLUP_REPLACE_ARCH` as any, + os: `ROLLUP_REPLACE_OS` as any, + gnArgs: `ROLLUP_REPLACE_GN_ARGS` + // tslint:disable:any +}; + +// TODO(kevinkassimo): deprecate Deno.platform +export const platform = build; diff --git a/js/platform_test.ts b/js/build_test.ts index 0149ef7a5..7ef39a040 100644 --- a/js/platform_test.ts +++ b/js/build_test.ts @@ -1,10 +1,14 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { test, assert } from "./test_util.ts"; -test(function platformTransform() { - // deno.platform is injected by rollup at compile time. Here +test(function buildInfo() { + // Deno.build is injected by rollup at compile time. Here // we check it has been properly transformed. - const { arch, os } = Deno.platform; + const { arch, os } = Deno.build; assert(arch === "x64"); assert(os === "mac" || os === "win" || os === "linux"); }); + +test(function buildGnArgs() { + assert(Deno.build.gnArgs.length > 100); +}); diff --git a/js/chmod_test.ts b/js/chmod_test.ts index 0b7dab9b4..f6eac05b0 100644 --- a/js/chmod_test.ts +++ b/js/chmod_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. import { testPerm, assertEqual } from "./test_util.ts"; -const isNotWindows = Deno.platform.os !== "win"; +const isNotWindows = Deno.build.os !== "win"; testPerm({ read: true, write: true }, function chmodSyncSuccess() { const enc = new TextEncoder(); diff --git a/js/deno.ts b/js/deno.ts index d13ca81dd..cd4ace4df 100644 --- a/js/deno.ts +++ b/js/deno.ts @@ -56,7 +56,6 @@ export { Permission, Permissions } from "./permissions"; -export { platform } from "./platform"; export { truncateSync, truncate } from "./truncate"; export { FileInfo } from "./file_info"; export { connect, dial, listen, Listener, Conn } from "./net"; @@ -64,6 +63,7 @@ export { metrics, Metrics } from "./metrics"; export { resources } from "./resources"; export { run, RunOptions, Process, ProcessStatus } from "./process"; export { inspect } from "./console"; +export { build, platform } from "./build"; export { version } from "./version"; export const args: string[] = []; diff --git a/js/dir_test.ts b/js/dir_test.ts index 8908f3da8..d2ddb137f 100644 --- a/js/dir_test.ts +++ b/js/dir_test.ts @@ -10,7 +10,7 @@ testPerm({ write: true }, function dirCwdChdirSuccess() { const path = Deno.makeTempDirSync(); Deno.chdir(path); const current = Deno.cwd(); - if (Deno.platform.os === "mac") { + if (Deno.build.os === "mac") { assertEqual(current, "/private" + path); } else { assertEqual(current, path); @@ -20,7 +20,7 @@ testPerm({ write: true }, function dirCwdChdirSuccess() { testPerm({ write: true }, function dirCwdError() { // excluding windows since it throws resource busy, while removeSync - if (["linux", "mac"].includes(Deno.platform.os)) { + if (["linux", "mac"].includes(Deno.build.os)) { const initialdir = Deno.cwd(); const path = Deno.makeTempDirSync(); Deno.chdir(path); diff --git a/js/platform.ts b/js/platform.ts deleted file mode 100644 index 9061b4ed3..000000000 --- a/js/platform.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. - -// Do not add unsupported platforms. -export interface Platform { - /** The operating system CPU architecture. */ - arch: "x64"; - - /** The operating system platform. */ - os: "mac" | "win" | "linux"; -} - -// 'platform' is injected by rollup.config.js at compile time. -export const platform: Platform = { - // tslint:disable:no-any - arch: "" as any, - os: "" as any - // tslint:disable:any -}; diff --git a/js/process_test.ts b/js/process_test.ts index 9603fb1c8..6613ff102 100644 --- a/js/process_test.ts +++ b/js/process_test.ts @@ -38,7 +38,7 @@ testPerm({ run: true }, async function runCommandFailedWithCode() { }); testPerm({ run: true }, async function runCommandFailedWithSignal() { - if (Deno.platform.os === "win") { + if (Deno.build.os === "win") { return; // No signals on windows. } const p = run({ diff --git a/js/read_link_test.ts b/js/read_link_test.ts index 045bf6250..cbef6334e 100644 --- a/js/read_link_test.ts +++ b/js/read_link_test.ts @@ -8,7 +8,7 @@ testPerm({ write: true, read: true }, function readlinkSyncSuccess() { Deno.mkdirSync(target); // TODO Add test for Windows once symlink is implemented for Windows. // See https://github.com/denoland/deno/issues/815. - if (Deno.platform.os !== "win") { + if (Deno.build.os !== "win") { Deno.symlinkSync(target, symlink); const targetPath = Deno.readlinkSync(symlink); assertEqual(targetPath, target); @@ -47,7 +47,7 @@ testPerm({ write: true, read: true }, async function readlinkSuccess() { Deno.mkdirSync(target); // TODO Add test for Windows once symlink is implemented for Windows. // See https://github.com/denoland/deno/issues/815. - if (Deno.platform.os !== "win") { + if (Deno.build.os !== "win") { Deno.symlinkSync(target, symlink); const targetPath = await Deno.readlink(symlink); assertEqual(targetPath, target); diff --git a/js/unit_tests.ts b/js/unit_tests.ts index a82ffb36c..e013de04e 100644 --- a/js/unit_tests.ts +++ b/js/unit_tests.ts @@ -5,6 +5,7 @@ import "./blob_test.ts"; import "./buffer_test.ts"; +import "./build_test.ts"; import "./chmod_test.ts"; // TODO find a way to test the compiler with split snapshots // import "./compiler_test.ts"; @@ -29,7 +30,6 @@ import "./mixins/dom_iterable_test.ts"; import "./mkdir_test.ts"; import "./net_test.ts"; import "./os_test.ts"; -import "./platform_test.ts"; import "./process_test.ts"; import "./read_dir_test.ts"; import "./read_file_test.ts"; diff --git a/js/version.ts b/js/version.ts index 984550a74..471072d81 100644 --- a/js/version.ts +++ b/js/version.ts @@ -3,14 +3,13 @@ interface Version { deno: string; v8: string; typescript: string; - gnArgs: string; } export const version: Version = { deno: "", v8: "", - typescript: "TS_VERSION", // This string will be replaced by rollup - gnArgs: `GN_ARGS` // This string will be replaced by rollup + // This string will be replaced by rollup + typescript: `ROLLUP_REPLACE_TS_VERSION` }; /** diff --git a/js/version_test.ts b/js/version_test.ts index bef00dbc3..d3d1bc3df 100644 --- a/js/version_test.ts +++ b/js/version_test.ts @@ -6,7 +6,3 @@ test(function version() { assert(pattern.test(Deno.version.v8)); assert(pattern.test(Deno.version.typescript)); }); - -test(function versionGnArgs() { - assert(Deno.version.gnArgs.length > 100); -}); diff --git a/js/write_file_test.ts b/js/write_file_test.ts index ba136bf5d..67419a7f6 100644 --- a/js/write_file_test.ts +++ b/js/write_file_test.ts @@ -45,7 +45,7 @@ testPerm({ write: false }, function writeFileSyncPerm() { }); testPerm({ read: true, write: true }, function writeFileSyncUpdatePerm() { - if (Deno.platform.os !== "win") { + if (Deno.build.os !== "win") { const enc = new TextEncoder(); const data = enc.encode("Hello"); const filename = Deno.makeTempDirSync() + "/test.txt"; @@ -146,7 +146,7 @@ testPerm({ read: true, write: false }, async function writeFilePerm() { }); testPerm({ read: true, write: true }, async function writeFileUpdatePerm() { - if (Deno.platform.os !== "win") { + if (Deno.build.os !== "win") { const enc = new TextEncoder(); const data = enc.encode("Hello"); const filename = Deno.makeTempDirSync() + "/test.txt"; |