summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/deno.ts2
-rw-r--r--js/platform.ts8
-rw-r--r--js/platform_test.ts10
-rw-r--r--js/types.ts30
4 files changed, 15 insertions, 35 deletions
diff --git a/js/deno.ts b/js/deno.ts
index 91f7ae1af..62816b8e1 100644
--- a/js/deno.ts
+++ b/js/deno.ts
@@ -16,7 +16,7 @@ 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 { platform } from "./platform";
export { trace } from "./trace";
export { truncateSync, truncate } from "./truncate";
export const args: string[] = [];
diff --git a/js/platform.ts b/js/platform.ts
index 26fc317a1..704ed0743 100644
--- a/js/platform.ts
+++ b/js/platform.ts
@@ -1,5 +1,3 @@
-// Dummy. Injected in rollup.config.js
-import { DenoArch, DenoPlatform } from "./types";
-
-export const arch: DenoArch = "unknown";
-export const platform: DenoPlatform = "unknown";
+import { Platform } from "./types";
+// 'platform' is injected by rollup.config.js at compile time.
+export const platform: Platform = {};
diff --git a/js/platform_test.ts b/js/platform_test.ts
index 80a1d9325..65cd2572d 100644
--- a/js/platform_test.ts
+++ b/js/platform_test.ts
@@ -2,8 +2,10 @@
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");
+test(function platformTransform() {
+ // deno.platform is injected by rollup at compile time. Here
+ // we check it has been properly transformed.
+ const { arch, os } = deno.platform;
+ assert(arch === "x64");
+ assert(os === "mac" || os === "win" || os === "linux");
});
diff --git a/js/types.ts b/js/types.ts
index 7a7bc44d9..3ef8f81e5 100644
--- a/js/types.ts
+++ b/js/types.ts
@@ -152,28 +152,8 @@ declare global {
}
}
-// 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";
+// Do not add unsupported platforms.
+export interface Platform {
+ arch?: "x64";
+ os?: "mac" | "win" | "linux";
+}