mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
Move Platform from types to platform
This commit is contained in:
parent
5307aa94e1
commit
ce9148943c
4 changed files with 24 additions and 12 deletions
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue