%% Merge the list values in `ToAdd' into the list found at key `Key' %% in proplist `C'. Don't duplicate items. New Items are added to the %% front of existing items. It is an error if the value at `Key' is %% not a list in `C'. MergeConfig = fun({Key, ToAdd}, C) -> case lists:keyfind(Key, 1, C) of false -> lists:keystore(Key, 1, C, {Key, ToAdd}); {Key, List} when is_list(List) -> %% remove items in ToAdd already in List ToAdd1 = [ I || I <- ToAdd, not lists:member(I, List) ], lists:keystore(Key, 1, C, {Key, ToAdd1 ++ List }) end end. {match, [ErtsNumber]} = re:run(erlang:system_info(otp_release), "(\\d+)", [{capture, [0], list}]), ErtsVsn = erlang:list_to_integer(ErtsNumber), AddErlOpts = if ErtsVsn >= 15 -> [{d, have_callback_support}]; true -> [] end, DevOnlyDeps = [{neotoma, "", {git, "https://github.com/seancribbs/neotoma.git", {branch, master}}}, {proper, "", {git, "https://github.com/bkearns/proper.git", {branch, master}}}], Config1 = MergeConfig({erl_opts, AddErlOpts}, CONFIG), ConfigPath = filename:dirname(SCRIPT), DevMarker = filename:join([ConfigPath, ".DEV_MODE"]), case filelib:is_file(DevMarker) of true -> lists:foldl(MergeConfig, Config1, [{deps, DevOnlyDeps}, {erl_opts, [{d, 'DEV_ONLY'}]}]); false -> Config1 end.