diff --git a/examples/chat/server_test.ts b/examples/chat/server_test.ts index e1b1c0e1276f..47e17314ba80 100644 --- a/examples/chat/server_test.ts +++ b/examples/chat/server_test.ts @@ -27,7 +27,7 @@ async function startServer(): Promise { } // TODO: https://github.com/denoland/deno/issues/4108 -const ignore = build.os == "win"; +const ignore = build.os == "windows"; test({ ignore, diff --git a/fs/copy_test.ts b/fs/copy_test.ts index 5323ac9e4fbb..1f3330226506 100644 --- a/fs/copy_test.ts +++ b/fs/copy_test.ts @@ -15,7 +15,7 @@ import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts"; const testdataDir = path.resolve("fs", "testdata"); // TODO(axetroy): Add test for Windows once symlink is implemented for Windows. -const isWindows = Deno.build.os === "win"; +const isWindows = Deno.build.os === "windows"; function testCopy(name: string, cb: (tempDir: string) => Promise): void { Deno.test({ diff --git a/fs/ensure_symlink_test.ts b/fs/ensure_symlink_test.ts index 2264a6c37f91..5fda1c86a0a8 100644 --- a/fs/ensure_symlink_test.ts +++ b/fs/ensure_symlink_test.ts @@ -9,7 +9,7 @@ import * as path from "../path/mod.ts"; import { ensureSymlink, ensureSymlinkSync } from "./ensure_symlink.ts"; const testdataDir = path.resolve("fs", "testdata"); -const isWindows = Deno.build.os === "win"; +const isWindows = Deno.build.os === "windows"; Deno.test("ensureSymlinkIfItNotExist", async function (): Promise { const testDir = path.join(testdataDir, "link_file_1"); diff --git a/fs/walk_test.ts b/fs/walk_test.ts index b054db4cf0db..ea9a33773bb2 100644 --- a/fs/walk_test.ts +++ b/fs/walk_test.ts @@ -3,8 +3,6 @@ const { remove } = Deno; import { walk, walkSync, WalkOptions, WalkEntry } from "./walk.ts"; import { assert, assertEquals, assertThrowsAsync } from "../testing/asserts.ts"; -const isWindows = Deno.build.os == "win"; - export function testWalk( setup: (arg0: string) => void | Promise, t: () => void | Promise, @@ -254,13 +252,13 @@ testWalk( try { await symlink(d + "/b", d + "/a/bb"); } catch (err) { - assert(isWindows); + assert(Deno.build.os == "windows"); assertEquals(err.message, "Not implemented"); } }, async function symlink(): Promise { // symlink is not yet implemented on Windows. - if (isWindows) { + if (Deno.build.os == "windows") { return; } diff --git a/http/file_server_test.ts b/http/file_server_test.ts index c377f3bda7ea..eff47c41bb0c 100644 --- a/http/file_server_test.ts +++ b/http/file_server_test.ts @@ -62,9 +62,9 @@ test("serveDirectory", async function (): Promise { // `Deno.FileInfo` is not completely compatible with Windows yet // TODO: `mode` should work correctly in the future. // Correct this test case accordingly. - Deno.build.os !== "win" && + Deno.build.os !== "windows" && assert(/(\s)*\([a-zA-Z-]{10}\)(\s)*<\/td>/.test(page)); - Deno.build.os === "win" && + Deno.build.os === "windows" && assert(/(\s)*\(unknown mode\)(\s)*<\/td>/.test(page)); assert(page.includes(`README.md`)); } finally { diff --git a/node/_fs/_fs_chmod_test.ts b/node/_fs/_fs_chmod_test.ts index a3d814b51d3b..e43f097881d6 100644 --- a/node/_fs/_fs_chmod_test.ts +++ b/node/_fs/_fs_chmod_test.ts @@ -5,7 +5,7 @@ import { chmod, chmodSync } from "./_fs_chmod.ts"; test({ name: "ASYNC: Permissions are changed (non-Windows)", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", async fn() { const tempFile: string = await Deno.makeTempFile(); const originalFileMode: number | null = (await Deno.lstat(tempFile)).mode; @@ -31,7 +31,7 @@ test({ test({ name: "SYNC: Permissions are changed (non-Windows)", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn() { const tempFile: string = Deno.makeTempFileSync(); const originalFileMode: number | null = Deno.lstatSync(tempFile).mode; diff --git a/node/_fs/_fs_chown_test.ts b/node/_fs/_fs_chown_test.ts index fd31a8c62e77..1c1393ac4a77 100644 --- a/node/_fs/_fs_chown_test.ts +++ b/node/_fs/_fs_chown_test.ts @@ -3,8 +3,9 @@ const { test } = Deno; import { fail, assertEquals } from "../../testing/asserts.ts"; import { chown, chownSync } from "./_fs_chown.ts"; -//chown is difficult to test. Best we can do is set the existing user id/group id again -const ignore = Deno.build.os == "win"; +// chown is difficult to test. Best we can do is set the existing user id/group +// id again +const ignore = Deno.build.os == "windows"; test({ ignore, diff --git a/node/_fs/_fs_readlink_test.ts b/node/_fs/_fs_readlink_test.ts index 151d3f78269c..4b2165f8a822 100644 --- a/node/_fs/_fs_readlink_test.ts +++ b/node/_fs/_fs_readlink_test.ts @@ -6,13 +6,13 @@ const testDir = Deno.makeTempDirSync(); const oldname = testDir + "/oldname"; const newname = testDir + "/newname"; -if (Deno.build.os !== "win") { +if (Deno.build.os !== "windows") { Deno.symlinkSync(oldname, newname); } test({ name: "readlinkSuccess", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", async fn() { const data = await new Promise((res, rej) => { readlink(newname, (err, data) => { @@ -30,7 +30,7 @@ test({ test({ name: "readlinkEncodeBufferSuccess", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", async fn() { const data = await new Promise((res, rej) => { readlink(newname, { encoding: "buffer" }, (err, data) => { @@ -48,7 +48,7 @@ test({ test({ name: "readlinkSyncSuccess", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn() { const data = readlinkSync(newname); assertEquals(typeof data, "string"); @@ -58,7 +58,7 @@ test({ test({ name: "readlinkEncodeBufferSuccess", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn() { const data = readlinkSync(newname, { encoding: "buffer" }); assert(data instanceof Uint8Array); diff --git a/node/os.ts b/node/os.ts index 7c61e910b1f7..27b054f4def9 100644 --- a/node/os.ts +++ b/node/os.ts @@ -146,7 +146,7 @@ export function hostname(): string { /** Returns an array containing the 1, 5, and 15 minute load averages */ export function loadavg(): number[] { - if (Deno.build.os == "win") { + if (Deno.build.os === "windows") { return [0, 0, 0]; } return Deno.loadavg(); @@ -222,4 +222,4 @@ export const constants = { }, }; -export const EOL = Deno.build.os == "win" ? fsEOL.CRLF : fsEOL.LF; +export const EOL = Deno.build.os == "windows" ? fsEOL.CRLF : fsEOL.LF; diff --git a/node/process.ts b/node/process.ts index 89d383e8ef1f..310a7e814042 100644 --- a/node/process.ts +++ b/node/process.ts @@ -7,10 +7,7 @@ const versions = { ...Deno.version, }; -const osToPlatform = (os: Deno.OperatingSystem): string => - os === "win" ? "win32" : os === "mac" ? "darwin" : os; - -const platform = osToPlatform(Deno.build.os); +const platform = Deno.build.os === "windows" ? "win32" : Deno.build.os; const { arch } = Deno.build; diff --git a/path/constants.ts b/path/constants.ts index 1e1eeeb493d4..97d3bcf58083 100644 --- a/path/constants.ts +++ b/path/constants.ts @@ -48,7 +48,7 @@ export const CHAR_EQUAL = 61; /* = */ export const CHAR_0 = 48; /* 0 */ export const CHAR_9 = 57; /* 9 */ -export const isWindows = build.os === "win"; +export const isWindows = build.os === "windows"; export const EOL = isWindows ? "\r\n" : "\n"; export const SEP = isWindows ? "\\" : "/"; export const SEP_PATTERN = isWindows ? /[\\/]+/ : /\/+/; diff --git a/path/globrex.ts b/path/globrex.ts index 0fe833a52ed1..868df797ae56 100644 --- a/path/globrex.ts +++ b/path/globrex.ts @@ -2,7 +2,7 @@ // MIT License // Copyright (c) 2018 Terkel Gjervig Nielsen -const isWin = Deno.build.os === "win"; +const isWin = Deno.build.os === "windows"; const SEP = isWin ? `(?:\\\\|\\/)` : `\\/`; const SEP_ESC = isWin ? `\\\\` : `/`; const SEP_RAW = isWin ? `\\` : `/`; diff --git a/path/globrex_test.ts b/path/globrex_test.ts index 27541a5c8c69..c52ed108e563 100644 --- a/path/globrex_test.ts +++ b/path/globrex_test.ts @@ -6,7 +6,7 @@ const { test } = Deno; import { assertEquals } from "../testing/asserts.ts"; import { GlobrexOptions, globrex } from "./globrex.ts"; -const isWin = Deno.build.os === "win"; +const isWin = Deno.build.os === "windows"; const t = { equal: assertEquals, is: assertEquals }; function match( diff --git a/signal/test.ts b/signal/test.ts index 95529a6e2a16..c4d1bf3a779e 100644 --- a/signal/test.ts +++ b/signal/test.ts @@ -5,7 +5,7 @@ import { signal, onSignal } from "./mod.ts"; test({ name: "signal() throws when called with empty signals", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn() { assertThrows( () => { @@ -20,7 +20,7 @@ test({ test({ name: "signal() iterates for multiple signals", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", fn: async (): Promise => { // This prevents the program from exiting. const t = setInterval(() => {}, 1000); @@ -61,7 +61,7 @@ test({ test({ name: "onSignal() registers and disposes of event handler", - ignore: Deno.build.os === "win", + ignore: Deno.build.os === "windows", async fn() { // This prevents the program from exiting. const t = setInterval(() => {}, 1000);