Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unneeded dependency if OTP covers it #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 1 addition & 3 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{erl_opts, [debug_info]}.

{deps, [
{jsone, "1.8.0"}
]}.
{deps, []}.

{project_plugins, [rebar3_hex]}.
13 changes: 13 additions & 0 deletions rebar.config.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{Deps0, Config0} = case lists:keytake(deps, 1, CONFIG) of
false -> {[], CONFIG};
{value, {deps, D}, Cfg} -> {D, Cfg}
end,

Deps = case list_to_integer(erlang:system_info(otp_release)) of
N when N >= 27 ->
Deps0;
_ ->
[{jsone, "1.8.0"} | Deps0]
end,

[{deps, Deps} | Config0].
9 changes: 1 addition & 8 deletions rebar.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
{"1.2.0",
[{<<"jsone">>,{pkg,<<"jsone">>,<<"1.8.0">>},0}]}.
[
{pkg_hash,[
{<<"jsone">>, <<"347FF1FA700E182E1F9C5012FA6D737B12C854313B9AE6954CA75D3987D6C06D">>}]},
{pkg_hash_ext,[
{<<"jsone">>, <<"08560B78624A12E0B5E7EC0271EC8CA38EF51F63D84D84843473E14D9B12618C">>}]}
].
[].
3 changes: 1 addition & 2 deletions src/rebar3_codecov.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
{registered, []},
{applications,
[kernel,
stdlib,
jsone
stdlib
]},
{env,[]},
{modules, []},
Expand Down
17 changes: 17 additions & 0 deletions src/rebar3_codecov.app.src.script
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[{application, rebar3_codecov, Config}] = CONFIG,

{Apps0, Config0} = case lists:keytake(applications, 1, Config) of
false ->
{[], CONFIG};
{value, {applications, A}, Cfg} ->
{A, Cfg}
end,

Apps = case list_to_integer(erlang:system_info(otp_release)) of
N when N >= 27 ->
Apps0;
_ ->
[jsone, rfc3339 | Apps0]
end,

[{application, rebar3_codecov, [{applications, Apps} | Config]}].
18 changes: 17 additions & 1 deletion src/rebar3_codecov_prv.erl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export_formats(State) ->
to_json(SrcDirs, Mod2Data, #{json := true}) ->
rebar_api:info("exporting ~s~n", [?JSON_OUT_FILE]),
{_SrcDirs, JSON} = maps:fold(fun format_array_to_list/3, {SrcDirs, []}, Mod2Data),
Binary = jsone:encode(#{<<"coverage">> => {JSON}}),
Binary = json_encode(#{<<"coverage">> => {JSON}}),
file:write_file(?JSON_OUT_FILE, Binary);
to_json(_, _, _) -> ok.

Expand Down Expand Up @@ -196,3 +196,19 @@ get_excluded_modules(AppInfo) ->
end,
rebar_api:info("Excluding modules from coverage report ~p~n", [ExcludeModules]),
ExcludeModules.

-ifdef(OTP_RELEASE).
-if(?OTP_RELEASE >= 27).
%% OTP 27 or higher
json_encode(Bin) ->
json:encode(Bin).
-else.
%% OTP 26 to 21.
json_encode(Bin) ->
jsone:encode(Bin).
-endif.
-else.
%% OTP 20 or lower.
json_encode(Bin) ->
jsone:encode(Bin).
-endif.