From 86d261dbf1653a7cc074f7749a19b211e53cca0a Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Fri, 22 Mar 2019 12:27:11 -0400 Subject: Attempt at support sys_config_src in shell --- src/rebar_templater.erl | 29 ++--------------------------- 1 file changed, 2 insertions(+), 27 deletions(-) (limited to 'src/rebar_templater.erl') diff --git a/src/rebar_templater.erl b/src/rebar_templater.erl index 929ca47..bc79db0 100644 --- a/src/rebar_templater.erl +++ b/src/rebar_templater.erl @@ -59,7 +59,7 @@ list_templates(State) -> %% Expand a single template's value list_template(Files, {Name, Type, File}, State) -> - case consult(load_file(Files, Type, File)) of + case rebar_string:consult(binary_to_list(load_file(Files, Type, File))) of {error, Reason} -> {error, {consult, File, Reason}}; TemplateTerms -> @@ -158,7 +158,7 @@ drop_var_docs([{K,V}|Rest]) -> [{K,V} | drop_var_docs(Rest)]. %% Load the template index, resolve all variables, and then execute %% the template. create({Template, Type, File}, Files, UserVars, Force, State) -> - TemplateTerms = consult(load_file(Files, Type, File)), + TemplateTerms = rebar_string:consult(binary_to_list(load_file(Files, Type, File))), Vars = drop_var_docs(override_vars(UserVars, get_template_vars(TemplateTerms, State))), maybe_warn_about_name(Vars), TemplateCwd = filename:dirname(File), @@ -394,31 +394,6 @@ load_file(_Files, file, Name) -> {ok, Bin} = file:read_file(Name), Bin. -%% Given a string or binary, parse it into a list of terms, ala file:consult/1 -consult(Str) when is_list(Str) -> - consult([], Str, []); -consult(Bin) when is_binary(Bin)-> - consult([], binary_to_list(Bin), []). - -consult(Cont, Str, Acc) -> - case erl_scan:tokens(Cont, Str, 0) of - {done, Result, Remaining} -> - case Result of - {ok, Tokens, _} -> - case erl_parse:parse_term(Tokens) of - {ok, Term} -> consult([], Remaining, [Term | Acc]); - {error, Reason} -> {error, Reason} - end; - {eof, _Other} -> - lists:reverse(Acc); - {error, Info, _} -> - {error, Info} - end; - {more, Cont1} -> - consult(Cont1, eof, Acc) - end. - - write_file(Output, Data, Force) -> %% determine if the target file already exists FileExists = filelib:is_regular(Output), -- cgit v1.1