summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitson Kelly <me@kitsonkelly.com>2018-10-04 21:20:14 +1000
committerRyan Dahl <ry@tinyclouds.org>2018-10-04 12:31:39 -0400
commitce9148943c4ffa43252e3692014489ebcff3d51e (patch)
tree07510ec5cc8ba385c137baaeeb3dff3192c68ce6
parent5307aa94e14d99a226366a275e011a60161c9c39 (diff)
Move Platform from types to platform
-rw-r--r--js/platform.ts21
-rw-r--r--js/read_link_test.ts4
-rw-r--r--js/types.ts6
-rw-r--r--rollup.config.js5
4 files changed, 24 insertions, 12 deletions
diff --git a/js/platform.ts b/js/platform.ts
index 704ed0743..d1732f73f 100644
--- a/js/platform.ts
+++ b/js/platform.ts
@@ -1,3 +1,20 @@
-import { Platform } from "./types";
+// 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 = {};
+export const platform: Platform = {
+ // tslint:disable:no-any
+ arch: "" as any,
+ os: "" as any
+ // tslint:disable:any
+};
diff --git a/js/read_link_test.ts b/js/read_link_test.ts
index 2df6b30d0..583847654 100644
--- a/js/read_link_test.ts
+++ b/js/read_link_test.ts
@@ -9,7 +9,7 @@ testPerm({ write: 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 !== "win32") {
+ if (deno.platform.os !== "win") {
deno.symlinkSync(target, symlink);
const targetPath = deno.readlinkSync(symlink);
assertEqual(targetPath, target);
@@ -36,7 +36,7 @@ testPerm({ write: 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 !== "win32") {
+ if (deno.platform.os !== "win") {
deno.symlinkSync(target, symlink);
const targetPath = await deno.readlink(symlink);
assertEqual(targetPath, target);
diff --git a/js/types.ts b/js/types.ts
index 3ef8f81e5..7af0a5201 100644
--- a/js/types.ts
+++ b/js/types.ts
@@ -151,9 +151,3 @@ declare global {
stackTraceLimit: number;
}
}
-
-// Do not add unsupported platforms.
-export interface Platform {
- arch?: "x64";
- os?: "mac" | "win" | "linux";
-}
diff --git a/rollup.config.js b/rollup.config.js
index e08604b00..4cb3197f5 100644
--- a/rollup.config.js
+++ b/rollup.config.js
@@ -108,9 +108,10 @@ function platform({ include, exclude } = {}) {
// Adapted from https://github.com/rollup/rollup-plugin-inject/blob/master/src/index.js
const arch = archNodeToDeno[process.arch];
const os = osNodeToDeno[process.platform];
+ // We do not have to worry about the interface here, because this is just to generate
+ // the actual runtime code, not any type information integrated into Deno
const magicString = new MagicString(`
-import { Platform } from "./types";
-export const platform: Platform = { arch: "${arch}", os:"${os}" };`);
+export const platform = { arch: "${arch}", os:"${os}" };`);
return {
code: magicString.toString(),
map: magicString.generateMap()