Current section
Files
Jump to
Current section
Files
src/protozoa@internal@project.erl
-module(protozoa@internal@project).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/protozoa/internal/project.gleam").
-export([root/0, src/0, name/0]).
-if(?OTP_RELEASE >= 27).
-define(MODULEDOC(Str), -moduledoc(Str)).
-define(DOC(Str), -doc(Str)).
-else.
-define(MODULEDOC(Str), -compile([])).
-define(DOC(Str), -compile([])).
-endif.
?MODULEDOC(false).
-file("src/protozoa/internal/project.gleam", 32).
?DOC(false).
-spec find_root(binary()) -> binary().
find_root(Path) ->
Toml = filepath:join(Path, <<"gleam.toml"/utf8>>),
case simplifile_erl:is_file(Toml) of
{ok, false} ->
find_root(filepath:join(Path, <<".."/utf8>>));
{error, _} ->
find_root(filepath:join(Path, <<".."/utf8>>));
{ok, true} ->
Path
end.
-file("src/protozoa/internal/project.gleam", 6).
?DOC(false).
-spec root() -> binary().
root() ->
find_root(<<"."/utf8>>).
-file("src/protozoa/internal/project.gleam", 10).
?DOC(false).
-spec src() -> binary().
src() ->
filepath:join(root(), <<"src"/utf8>>).
-file("src/protozoa/internal/project.gleam", 14).
?DOC(false).
-spec name() -> {ok, binary()} | {error, nil}.
name() ->
Configuration_path = filepath:join(root(), <<"gleam.toml"/utf8>>),
gleam@result:'try'(
begin
_pipe = simplifile:read(Configuration_path),
gleam@result:map_error(_pipe, fun(_) -> nil end)
end,
fun(Configuration) ->
gleam@result:'try'(
begin
_pipe@1 = tom:parse(Configuration),
gleam@result:map_error(_pipe@1, fun(_) -> nil end)
end,
fun(Toml) ->
gleam@result:'try'(
begin
_pipe@2 = tom:get_string(Toml, [<<"name"/utf8>>]),
gleam@result:map_error(_pipe@2, fun(_) -> nil end)
end,
fun(Name) -> {ok, Name} end
)
end
)
end
).