Skip to content

Commit

Permalink
Fix deno
Browse files Browse the repository at this point in the history
  • Loading branch information
DitherWither committed Aug 22, 2024
1 parent 3baa631 commit 669d5c5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# platform
Zero dependency platform detection library for gleam

[![Package Version](https://img.shields.io/hexpm/v/platform)](https://hex.pm/packages/platform)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/platform/)
Expand Down
51 changes: 24 additions & 27 deletions src/platform_ffi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,37 @@ export function runtime() {
}

return "unknown";

}

export function os() {
const currentRuntime = runtime();

if (currentRuntime === "node" || currentRuntime === "bun") {
return process.platform;
}
if (currentRuntime === "browser") {
// TODO get browser's host os using user agent data
return "unknown";
}
// if (currentRuntime === "deno") {
// const {platform} = await import("node:process")
// return platform;
// }
const currentRuntime = runtime();

if (currentRuntime === "node" || currentRuntime === "bun") {
return process.platform;
}
if (currentRuntime === "browser") {
// TODO get browser's host os using user agent data
return "unknown";
}
if (currentRuntime === "deno") {
return Deno.build.os;
}
return "unknown";
}

export function arch() {
const currentRuntime = runtime();

if (currentRuntime === "node" || currentRuntime === "bun") {
return process.arch;
}
// if (currentRuntime === "deno") {
// const {arch} = await import("node:process")
// return arch;
// }
if (currentRuntime === "browser") {
// TODO get browser's architecture using user agent data
return "unknown";
}
const currentRuntime = runtime();

if (currentRuntime === "node" || currentRuntime === "bun") {
return process.arch;
}
if (currentRuntime === "deno") {
return Deno.build.arch;
}
if (currentRuntime === "browser") {
// TODO get browser's architecture using user agent data
return "unknown";
}

return "unknown";
}

0 comments on commit 669d5c5

Please sign in to comment.