-
Notifications
You must be signed in to change notification settings - Fork 3
/
platform.gleam
60 lines (50 loc) · 1.01 KB
/
platform.gleam
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// #TODO: externalize this to a seperate package
pub type OsName {
Win32
Linux
Darwin
Solaris
Sunos
Freebsd
Openbsd
}
pub type Arch {
X64
Ia32
Arm64
Arm
Ppc64
}
@external(erlang, "ffi_esgleam", "get_os")
@external(javascript, "../../ffi_esgleam.mjs", "get_os")
pub fn get_os() -> Result(OsName, Nil)
@external(erlang, "ffi_esgleam", "get_arch")
@external(javascript, "../../ffi_esgleam.mjs", "get_arch")
pub fn get_arch() -> Result(Arch, Nil)
pub fn get_package_name() {
let assert Ok(os) = get_os()
let assert Ok(arch) = get_arch()
let os_str = case os {
Win32 -> "win32"
Linux -> "linux"
Darwin -> "darwin"
Solaris | Sunos -> "sunos"
Freebsd -> "freebsd"
Openbsd -> "openbsd"
}
let arch_str = case arch {
X64 -> "x64"
Ia32 -> "ia32"
Arm64 -> "arm64"
Arm -> "arm"
Ppc64 -> "ppc64"
}
"@esbuild/" <> os_str <> "-" <> arch_str
}
pub fn get_exe_name() {
let assert Ok(os) = get_os()
case os {
Win32 -> "esbuild.exe"
_ -> "esbuild"
}
}