Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/setup_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ start(_Type, _Args) ->
setup_sup:start_link().

start_phase(run_setup, _Type, []) ->
_ = setup_srv:run_setup(),
case application:get_env(setup, auto_run_phases, true) of
true ->
_ = setup_srv:run_setup();
false ->
ignore
end,
ok.

stop(_) ->
Expand Down
34 changes: 34 additions & 0 deletions src/setup_file.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
close/1,
read_file/1,
consult/1,
consult_binary/1,
eval_binary/1,
eval_binary/2,
script/1,
script/2]).

Expand Down Expand Up @@ -88,6 +91,37 @@ consult(File) ->
Other
end.

%% @doc Like {@link file:consult/1}, but operates directly on a binary.
%%
%% This function works as if
%% `file:consult(F) -> {ok,Bin} = file:read_file(F), consult_binary(Bin).'
%% @end
consult_binary(Bin) when is_binary(Bin) ->
{ok, Fd} = open_bin(Bin, [read]),
try consult_stream(Fd)
after
_ = close(Fd)
end.

%% @doc Like {@link file:script/1}, but operates directly on a binary.
%%
%% This function works as if
%% `file:script(F) -> {ok,Bin} = file:read_file(F), eval_binary(Bin).'
%% @end
eval_binary(Bin) ->
eval_binary(Bin, []).

%% @doc Like {@link file:script/2}, but operates directly on a binary.
%%
%% This function works as if
%% `file:script(F, Bs) -> {ok,Bin} = file:read_file(F), eval_binary(Bin, Bs).'
%% @end
eval_binary(Bin, Bindings) when is_binary(Bin) ->
{ok, Fd} = open_bin(Bin, [read]),
try eval_stream(Fd, return, Bindings)
after
_ = file:close(Fd)
end.

%% @doc Like {@link file:script/1}, but supports paths into `zip' and `escript' archives
%%
Expand Down