|
4 | 4 |
|
5 | 5 | -export([init/1, |
6 | 6 | do/1, |
7 | | - format_error/1]). |
| 7 | + format_error/1, |
| 8 | + list_local_plugins/1]). |
8 | 9 |
|
9 | 10 | -include("rebar.hrl"). |
10 | 11 | -include_lib("providers/include/providers.hrl"). |
@@ -41,22 +42,35 @@ do(State) -> |
41 | 42 |
|
42 | 43 | RebarOpts = rebar_state:opts(State), |
43 | 44 | SrcDirs = rebar_dir:src_dirs(RebarOpts, ["src"]), |
44 | | - Plugins = rebar_state:get(State, plugins, []), |
45 | | - ProjectPlugins = rebar_state:get(State, project_plugins, []), |
| 45 | + {LocalPluginsDefs, _} = list_local_plugins(State), |
46 | 46 | PluginsDirs = filelib:wildcard(filename:join(rebar_dir:plugins_dir(State), "*")), |
47 | 47 |
|
48 | 48 | %% use `checkouts_dir' and not `checkouts_out_dir'. Since we use `all' in `find_apps' |
49 | 49 | %% so it doesn't need to be built and the apps in `checkouts_dir' could be old |
50 | 50 | %% because the user removing from `_checkouts/' doesn't cause removal of the output |
51 | 51 | CheckoutsDirs = filelib:wildcard(filename:join(rebar_dir:checkouts_dir(State), "*")), |
52 | 52 | Apps = rebar_app_discover:find_apps(CheckoutsDirs++PluginsDirs, SrcDirs, all, State), |
53 | | - display_plugins("Local plugins", Apps, Plugins ++ ProjectPlugins), |
| 53 | + display_plugins("Local plugins", Apps, LocalPluginsDefs), |
54 | 54 | {ok, State}. |
55 | 55 |
|
56 | 56 | -spec format_error(any()) -> iolist(). |
57 | 57 | format_error(Reason) -> |
58 | 58 | io_lib:format("~p", [Reason]). |
59 | 59 |
|
| 60 | +list_local_plugins(State) -> |
| 61 | + LocalPluginsDefs = rebar_state:get(State, plugins, []) |
| 62 | + ++ rebar_state:get(State, project_plugins, []), |
| 63 | + LocalPluginsNames = lists:map( |
| 64 | + fun (LocalPluginDef) -> |
| 65 | + rebar_utils:to_atom( |
| 66 | + if is_tuple(LocalPluginDef) -> element(1, LocalPluginDef); |
| 67 | + LocalPluginDef -> LocalPluginDef |
| 68 | + end |
| 69 | + ) |
| 70 | + end, |
| 71 | + LocalPluginsDefs), |
| 72 | + {LocalPluginsDefs, LocalPluginsNames}. |
| 73 | + |
60 | 74 | display_plugins(_Header, _Apps, []) -> |
61 | 75 | ok; |
62 | 76 | display_plugins(Header, Apps, Plugins) -> |
|
0 commit comments