From a59f5eadd86e85bf662b37ec40ceb6f80cb207c4 Mon Sep 17 00:00:00 2001 From: Behnam Mohammadi Date: Sat, 14 Nov 2020 02:51:11 +0330 Subject: refactor(std): add std/_util/os.ts module (#8370) This commit adds "std/_util/os.ts" module which contains common os detection logic and is browser compatible. Co-authored-by: Nayeem Rahman --- std/_util/os.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 std/_util/os.ts (limited to 'std/_util') diff --git a/std/_util/os.ts b/std/_util/os.ts new file mode 100644 index 000000000..50c70b134 --- /dev/null +++ b/std/_util/os.ts @@ -0,0 +1,18 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +// This module is browser compatible. + +export const osType = (() => { + if (globalThis.Deno != null) { + return Deno.build.os; + } + + // deno-lint-ignore no-explicit-any + const navigator = (globalThis as any).navigator; + if (navigator?.appVersion?.includes?.("Win") ?? false) { + return "windows"; + } + + return "linux"; +})(); + +export const isWindows = osType === "windows"; -- cgit v1.2.3