提交 ce914894 编写于 作者: K Kitson Kelly 提交者: Ryan Dahl

Move Platform from types to platform

上级 5307aa94
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
};
......@@ -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);
......
......@@ -151,9 +151,3 @@ declare global {
stackTraceLimit: number;
}
}
// Do not add unsupported platforms.
export interface Platform {
arch?: "x64";
os?: "mac" | "win" | "linux";
}
......@@ -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()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册