소스 검색

Fix consult_and_eval/2 to behave like consult

pull/821/head
Heinz N. Gies 9 년 전
부모
커밋
0867cadbd7
1개의 변경된 파일15개의 추가작업 그리고 1개의 파일을 삭제
  1. +15
    -1
      src/rebar_config.erl

+ 15
- 1
src/rebar_config.erl 파일 보기

@ -109,10 +109,24 @@ format_error({bad_dep_name, Dep}) ->
%% Internal functions
%% ===================================================================
-spec consult_and_eval(File::file:name_all(), Script::file:name_all()) ->
{ok, Terms::[term()]} |
{error, Reason::term()}.
consult_and_eval(File, Script) ->
?DEBUG("Evaluating config script ~p", [Script]),
StateData = rebar_file_utils:try_consult(File),
file:script(Script, bs([{'CONFIG', StateData}, {'SCRIPT', Script}])).
%% file:consult/1 always returns the terms as a list, however file:script
%% can (and will) return any kind of term(), to make consult_and_eval
%% work the same way as eval we ensure that when no list is returned we
%% convert it in a list.
case file:script(Script, bs([{'CONFIG', StateData}, {'SCRIPT', Script}])) of
{ok, Terms} when is_list(Terms) ->
{ok, Terms};
{ok, Term} ->
{ok, [Term]};
Error ->
Error
end.
remove_script_ext(F) ->
filename:rootname(F, ".script").

불러오는 중...
취소
저장