diff options
Diffstat (limited to 'ext/node/polyfills/_util/os.ts')
-rw-r--r-- | ext/node/polyfills/_util/os.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/ext/node/polyfills/_util/os.ts b/ext/node/polyfills/_util/os.ts new file mode 100644 index 000000000..66d18534c --- /dev/null +++ b/ext/node/polyfills/_util/os.ts @@ -0,0 +1,22 @@ +// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. + +export type OSType = "windows" | "linux" | "darwin" | "freebsd"; + +export const osType: OSType = (() => { + // deno-lint-ignore no-explicit-any + const { Deno } = globalThis as any; + if (typeof Deno?.build?.os === "string") { + return Deno.build.os; + } + + // deno-lint-ignore no-explicit-any + const { navigator } = globalThis as any; + if (navigator?.appVersion?.includes?.("Win")) { + return "windows"; + } + + return "linux"; +})(); + +export const isWindows = osType === "windows"; +export const isLinux = osType === "linux"; |