Skip to content

Commit

Permalink
fixup(js): sys.platform not compile on JS
Browse files Browse the repository at this point in the history
  • Loading branch information
litlighilit committed Aug 8, 2024
1 parent 1cf0067 commit 6a3a976
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/pylib/Lib/sys.nim
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ when not weirdTarget and not defined(windows):

proc getPlatform(): string =
when defined(js):
template inString(jo: JsObject): string =
$(jo.to(cstring))
when defined(nodejs):
return $require("os").platform()
return require("os").platform().inString
else:
let navigator{.importcpp.}: JsObject
result = ($navigator.platform).toLowerAscii
result = navigator.platform.inString.toLowerAscii
result =
if result.startsWith "win32": "win32"
elif result.startsWith "linux": "linux"
Expand Down

0 comments on commit 6a3a976

Please sign in to comment.