diff options
Diffstat (limited to 'js')
-rw-r--r-- | js/deno.ts | 1 | ||||
-rw-r--r-- | js/platform.ts | 5 | ||||
-rw-r--r-- | js/platform_test.ts | 9 | ||||
-rw-r--r-- | js/types.ts | 26 | ||||
-rw-r--r-- | js/unit_tests.ts | 1 |
5 files changed, 42 insertions, 0 deletions
diff --git a/js/deno.ts b/js/deno.ts index 7d52441ec..9be05e916 100644 --- a/js/deno.ts +++ b/js/deno.ts @@ -12,4 +12,5 @@ export { symlinkSync, symlink } from "./symlink"; export { writeFileSync, writeFile } from "./write_file"; export { ErrorKind, DenoError } from "./errors"; export { libdeno } from "./libdeno"; +export { arch, platform } from "./platform"; export const argv: string[] = []; diff --git a/js/platform.ts b/js/platform.ts new file mode 100644 index 000000000..26fc317a1 --- /dev/null +++ b/js/platform.ts @@ -0,0 +1,5 @@ +// Dummy. Injected in rollup.config.js +import { DenoArch, DenoPlatform } from "./types"; + +export const arch: DenoArch = "unknown"; +export const platform: DenoPlatform = "unknown"; diff --git a/js/platform_test.ts b/js/platform_test.ts new file mode 100644 index 000000000..80a1d9325 --- /dev/null +++ b/js/platform_test.ts @@ -0,0 +1,9 @@ +// Copyright 2018 the Deno authors. All rights reserved. MIT license. +import { test, assert } from "./test_util.ts"; +import * as deno from "deno"; + +test(function transformPlatformSuccess() { + // Make sure they are transformed + assert(deno.arch !== "unknown"); + assert(deno.platform !== "unknown"); +}); diff --git a/js/types.ts b/js/types.ts index 7af0a5201..7a7bc44d9 100644 --- a/js/types.ts +++ b/js/types.ts @@ -151,3 +151,29 @@ declare global { stackTraceLimit: number; } } + +// Based on Node's arch +export type DenoArch = + | "arm" + | "arm64" + | "ia32" + | "mips" + | "mipsel" + | "ppc" + | "ppc64" + | "s390" + | "s390x" + | "x32" + | "x64" + | "unknown"; + +export type DenoPlatform = + | "aix" + | "darwin" + | "freebsd" + | "linux" + | "openbsd" + | "sunos" + | "win32" + | "android" + | "unknown"; diff --git a/js/unit_tests.ts b/js/unit_tests.ts index f1eed319e..a535aea55 100644 --- a/js/unit_tests.ts +++ b/js/unit_tests.ts @@ -14,3 +14,4 @@ import "./rename_test.ts"; import "./blob_test.ts"; import "./timers_test.ts"; import "./symlink_test.ts"; +import "./platform_test.ts"; |