Skip to content

Commit

Permalink
check if cuttlefish escript exists in profile dir, if not check default
Browse files Browse the repository at this point in the history
  • Loading branch information
tsloughter committed Feb 23, 2016
1 parent f155312 commit 969e14f
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/rebar3_cuttlefish_release.erl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@ do(State) ->
CFConf = rebar_state:get(State, cuttlefish, []),

ReleaseDir = filename:join(rebar_dir:base_dir(State), "rel"),
BinDir = filename:join(rebar_dir:base_dir(State), "bin"),
BinDir = case filelib:is_regular(filename:join([rebar_dir:base_dir(State), "bin", "cuttlefish"])) of
true ->
filename:join(rebar_dir:base_dir(State), "bin");
false ->
case filelib:is_regular(filename:join(["_build/default", "bin", "cuttlefish"])) of
true ->
"_build/default/bin";
false ->
throw({no_cuttlefish_escript, rebar_dir:base_dir(State)})
end
end,


{release, {Name, _Vsn}, _} = lists:keyfind(release, 1, Relx),
CFFile = case lists:keyfind(file_name, 1, CFConf) of
{file_name, DefinedFileName} ->
Expand Down Expand Up @@ -87,6 +99,9 @@ do(State) ->
end.

-spec format_error(any()) -> iolist().
format_error({no_cuttlefish_escript, ProfileDir}) ->
io_lib:format("No cuttlefish escript found under ~s or ~s", [filename:join(ProfileDir, "bin"),
"_build/default/bin"]);
format_error(Error) ->
io_lib:format("~p", [Error]).

Expand Down

0 comments on commit 969e14f

Please sign in to comment.