From 67db07f0dcaae94b08b02c6dae0813c4148b9d9a Mon Sep 17 00:00:00 2001 From: Vasu Dasari Date: Fri, 20 Apr 2018 13:23:39 -0400 Subject: [PATCH] Issue 27: Reset ERL_FLAGS before making rebar_utils:sh() calls Make a wrapper for rebar_utils:sh() so that this plugin can invoke elixir/mix commands with ERL_FLAGS set to "". This is done so that the settings of ERL_FLAGS do not influence these commands. For more information refer to: Issue 27, https://github.com/barrel-db/rebar3_elixir_compile/issues/27 --- src/rebar3_elixir_compile_util.erl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rebar3_elixir_compile_util.erl b/src/rebar3_elixir_compile_util.erl index f84bba2..20637b9 100644 --- a/src/rebar3_elixir_compile_util.erl +++ b/src/rebar3_elixir_compile_util.erl @@ -63,7 +63,7 @@ get_details(State) -> LibDir = case lists:keyfind(lib_dir, 1, Config) of false -> - {ok, ElixirLibs_} = rebar_utils:sh("elixir -e \"IO.puts :code.lib_dir(:elixir)\"", []), + {ok, ElixirLibs_} = sh("elixir -e \"IO.puts :code.lib_dir(:elixir)\"", []), filename:join(re:replace(ElixirLibs_, "\\s+", "", [global,{return,list}]), "../"); {lib_dir, Dir2} -> Dir2 end, @@ -229,8 +229,8 @@ compile_libs(State, [App | Apps], AddToPath) -> Profile = profile(Env), case {ec_file:exists(filename:join(AppDir, "mix.exs")), ec_file:exists(filename:join(AppDir, "rebar.config"))} of {true, false} -> - rebar_utils:sh(Profile ++ Mix ++ "deps.get", [{cd, AppDir}, {use_stdout, true}]), - rebar_utils:sh(Profile ++ Mix ++ "compile", [{cd, AppDir}, {use_stdout, true}]), + sh(Profile ++ Mix ++ "deps.get", [{cd, AppDir}, {use_stdout, true}]), + sh(Profile ++ Mix ++ "compile", [{cd, AppDir}, {use_stdout, true}]), LibsDir = libs_dir(AppDir, Env), {ok, Libs} = file:list_dir_all(LibsDir), transfer_libs(State, Libs, LibsDir); @@ -282,3 +282,6 @@ maybe_copy_dir(Source, Target, CreateNew) -> ec_file:remove(TargetDir, [recurisve]), ec_file:copy(Source, TargetDir, [recursive]) end. + +sh(Command, Options) -> + rebar_utils:sh(Command, [{env, [{"ERL_FLAGS", ""}]} | Options]).