diff options
author | Tino Breddin <t@tolbrino.com> | 2019-02-22 11:31:13 +0100 |
---|---|---|
committer | Tino Breddin <t@tolbrino.com> | 2019-03-22 11:29:48 +0100 |
commit | 9c28e9122ddc5500e5ce70da6aa06d59dd8a2563 (patch) | |
tree | 1b4bfff9891077b002fb4ebf0e70693fe462608d | |
parent | 3e19dcfa7f95145ec2a4c70fbc44208f4bd6345d (diff) |
Fix provider hook handling for escriptize
Previously all escriptize hooks from all apps in the project were
executed, which could lead to issue in case of dependencies on artifacts
which are created by these hooks.
Now the behaviour is similar to the handling of other non-global hooks.
-rw-r--r-- | src/rebar_prv_escriptize.erl | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/rebar_prv_escriptize.erl b/src/rebar_prv_escriptize.erl index fceb65e..9cb3fdd 100644 --- a/src/rebar_prv_escriptize.erl +++ b/src/rebar_prv_escriptize.erl @@ -63,13 +63,11 @@ desc() -> do(State) -> Providers = rebar_state:providers(State), Cwd = rebar_state:dir(State), - rebar_hooks:run_project_and_app_hooks(Cwd, pre, ?PROVIDER, Providers, State), - ?INFO("Building escript...", []), - Res = case rebar_state:get(State, escript_main_app, undefined) of + AppInfo0 = case rebar_state:get(State, escript_main_app, undefined) of undefined -> case rebar_state:project_apps(State) of - [App] -> - escriptize(State, App); + [AppInfo] -> + AppInfo; _ -> ?PRV_ERROR(no_main_app) end; @@ -77,12 +75,15 @@ do(State) -> AllApps = rebar_state:all_deps(State)++rebar_state:project_apps(State), case rebar_app_utils:find(rebar_utils:to_binary(Name), AllApps) of {ok, AppInfo} -> - escriptize(State, AppInfo); + AppInfo; _ -> ?PRV_ERROR({bad_name, Name}) end end, - rebar_hooks:run_project_and_app_hooks(Cwd, post, ?PROVIDER, Providers, State), + AppInfo1 = rebar_hooks:run_all_hooks(Cwd, pre, ?PROVIDER, Providers, AppInfo0, State), + ?INFO("Building escript...", []), + Res = escriptize(State, AppInfo1), + rebar_hooks:run_all_hooks(Cwd, post, ?PROVIDER, Providers, AppInfo1, State), Res. escriptize(State0, App) -> |