diff --git a/README.md b/README.md index 59be2d6..ede58b7 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,9 @@ Prerequisite ----- On Linux you need to install inotify-tools. +``` +-m: 1: inotifywait: not found +``` Use --- @@ -45,3 +48,16 @@ Compiling relx 1> ``` + +Custom extensions, thanks abxy. +Regex matches are supported, "$" is suffixed automatically, thanks xuchaoqian. +``` +re:run(<<"file_name.erl_ab">>, <>) +``` + +``` +To extend the list add an option to your rebar.config like so: + +{extra_extensions, [".alp", ".hterl", ".erl(.*?)"]}. + +``` \ No newline at end of file diff --git a/rebar.lock b/rebar.lock index 144fe69..6ca378f 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1 +1,6 @@ -[{<<"enotify">>,{pkg,<<"enotify">>,<<"0.1.0">>},0}]. +{"1.1.0", +[{<<"enotify">>,{pkg,<<"enotify">>,<<"0.1.0">>},0}]}. +[ +{pkg_hash,[ + {<<"enotify">>, <<"F6BF33AA7BC4789D953087E48C6ADBC6D9682B6D67E4BC353C2FDB96C5AC5595">>}]} +]. diff --git a/src/rebar3_auto.app.src b/src/rebar3_auto.app.src index b1a4184..cbb02db 100644 --- a/src/rebar3_auto.app.src +++ b/src/rebar3_auto.app.src @@ -1,6 +1,6 @@ {application,rebar3_auto, [{description,"Rebar3 plugin for auto compiling on changes"}, - {vsn,"0.3.2"}, + {vsn,"0.3.3"}, {registered,[]}, {applications,[kernel,stdlib,enotify]}, {env,[]}, diff --git a/src/rebar3_auto.erl b/src/rebar3_auto.erl index d6256a0..85df764 100644 --- a/src/rebar3_auto.erl +++ b/src/rebar3_auto.erl @@ -20,7 +20,7 @@ ,do/1 ,format_error/1]). --export([auto/0, flush/0]). +-export([auto/1, flush/0]). -define(PROVIDER, auto). -define(DEPS, [compile]). @@ -70,15 +70,20 @@ format_error(Reason) -> do(State) -> spawn(fun() -> listen_on_project_apps(State), - ?MODULE:auto() + Extensions = get_extensions(State), + ?MODULE:auto(Extensions) end), State1 = remove_from_plugin_paths(State), rebar_prv_shell:do(State1). --define(VALID_EXTENSIONS,[<<".erl">>, <<".hrl">>, <<".src">>, <<".lfe">>, <<".config">>, <<".lock">>, +-define(VALID_EXTENSIONS_DEFAULT,[<<".erl">>, <<".hrl">>, <<".src">>, <<".lfe">>, <<".config">>, <<".lock">>, <<".c">>, <<".cpp">>, <<".h">>, <<".hpp">>, <<".cc">>]). -auto() -> +get_extensions(State) -> + ExtraExtensions = rebar_state:get(State, extra_extensions, []), + [unicode:characters_to_binary(Ext) || Ext <- ExtraExtensions] ++ ?VALID_EXTENSIONS_DEFAULT. + +auto(Extensions) -> case whereis(rebar_agent) of undefined -> timer:sleep(100); @@ -87,7 +92,19 @@ auto() -> receive {ChangedFile, _Events} -> Ext = filename:extension(unicode:characters_to_binary(ChangedFile)), - IsValid = lists:member(Ext, ?VALID_EXTENSIONS), + IsValid = lists:any( + fun(ValidExt) -> + RE = <>, + Result = re:run(Ext, RE), + case Result of + {match, _Captured} -> true; + match -> true; + nomatch -> false; + {error, _ErrType} -> false + end + end, + Extensions + ), case IsValid of false -> pass; true -> @@ -101,7 +118,7 @@ auto() -> end end, - ?MODULE:auto(). + ?MODULE:auto(Extensions). flush() -> receive