Packages
lustre
4.0.0-rc.2
5.7.1
5.7.0
5.6.0
5.5.2
5.5.1
5.5.0
5.4.0
5.3.5
5.3.4
5.3.3
5.3.2
5.3.1
5.3.0
5.2.1
5.2.0
5.1.1
5.1.0
5.0.3
5.0.2
5.0.1
5.0.0
4.6.4
4.6.3
4.6.2
4.6.1
4.6.0
4.5.1
4.5.0
4.4.4
4.4.3
4.4.1
4.4.0
4.3.6
4.3.5
4.3.4
4.3.3
4.3.2
4.3.1
4.3.0
4.2.6
4.2.5
4.2.4
4.2.3
4.2.2
4.2.1
4.2.0
4.1.8
4.1.7
4.1.6
4.1.5
4.1.4
4.1.3
4.1.2
4.1.1
4.1.0
4.0.0
4.0.0-rc1
4.0.0-rc.2
3.1.4
3.1.3
3.1.2
3.1.1
3.1.0
3.0.12
3.0.11
3.0.10
3.0.9
3.0.8
3.0.7
3.0.6
3.0.5
3.0.4
3.0.3
3.0.2
3.0.1
3.0.0
3.0.0-rc.8
3.0.0-rc.7
3.0.0-rc.6
3.0.0-rc.5
3.0.0-rc.4
3.0.0-rc.3
3.0.0-rc.2
3.0.0-rc.1
2.0.1
2.0.0
1.3.0
1.2.0
1.1.0
1.0.0
Create HTML templates, single page applications, Web Components, and real-time server components in Gleam!
Current section
Files
Jump to
Current section
Files
src/cli_ffi.erl
-module(cli_ffi).
-export([
get_cpu/0,
get_esbuild/1,
get_os/0,
unzip_esbuild/1
]).
get_os() ->
case os:type() of
{win32, _} -> <<"win32">>;
{unix, darwin} -> <<"darwin">>;
{unix, linux} -> <<"linux">>;
{_, Unknown} -> atom_to_binary(Unknown, utf8)
end.
get_cpu() ->
case erlang:system_info(os_type) of
{unix, _} ->
[Arch, _] = string:split(erlang:system_info(system_architecture), "-"),
list_to_binary(Arch);
{win32, _} ->
case erlang:system_info(wordsize) of
4 -> {ok, <<"ia32">>};
8 -> {ok, <<"x64">>}
end
end.
get_esbuild(Url) ->
inets:start(),
ssl:start(),
case httpc:request(get, {Url, []}, [], [{body_format, binary}]) of
{ok, {{_, 200, _}, _, Zip}} -> {ok, Zip};
{ok, Res} -> {error, Res};
{error, Err} -> {error, Err}
end.
unzip_esbuild(Zip) ->
Result =
erl_tar:extract({binary, Zip}, [
memory, compressed, {files, ["package/bin/esbuild"]}
]),
case Result of
{ok, [{_, Esbuild}]} -> {ok, Esbuild};
{ok, Res} -> {error, Res};
{error, Err} -> {error, Err}
end.