std/path/_os.ts
Ben McLean c3b113d7a9
refactor(path): make isWindows check compatible with Node and Bun (#4961)
* Refactored to get rid of unnecessary function.

All that needs to be done here is to check if
the version is windows. Handling each combination
of runtime and operating system will make
the existing osType difficult to test and maintain.

* Changed browser version of isWindows.

It was using a deprecated web API.

* Refactored getIsWindows.

* Added node/bun version of isWindows.

* Got cross platform os module working.

* Handled Deno error.

* Fixed type errors.

* Removed node:os import.

This is how NodeJS checks to see
if the underlying OS is windows.

* tweaks

* fix

* cleanup

* tweak

* fix

* Added support for node.

---------

Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
2024-08-30 08:39:59 +10:00

11 lines
454 B
TypeScript

// deno-lint-ignore-file no-explicit-any
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
// Check Deno, then the remaining runtimes (e.g. Node, Bun and the browser)
export const isWindows: boolean =
(globalThis as any).Deno?.build.os === "windows" ||
(globalThis as any).navigator?.platform?.startsWith("Win") ||
(globalThis as any).process?.platform?.startsWith("win") ||
false;