2020 ,do /1
2121 ,format_error /1 ]).
2222
23- -export ([auto /0 , flush /0 ]).
23+ -export ([auto /1 , flush /0 ]).
2424
2525-define (PROVIDER , auto ).
2626-define (DEPS , [compile ]).
@@ -70,15 +70,20 @@ format_error(Reason) ->
7070do (State ) ->
7171 spawn (fun () ->
7272 listen_on_project_apps (State ),
73- ? MODULE :auto ()
73+ Extensions = get_extensions (State ),
74+ ? MODULE :auto (Extensions )
7475 end ),
7576 State1 = remove_from_plugin_paths (State ),
7677 rebar_prv_shell :do (State1 ).
7778
78- -define (VALID_EXTENSIONS ,[<<" .erl" >>, <<" .hrl" >>, <<" .src" >>, <<" .lfe" >>, <<" .config" >>, <<" .lock" >>,
79+ -define (VALID_EXTENSIONS_DEFAULT ,[<<" .erl" >>, <<" .hrl" >>, <<" .src" >>, <<" .lfe" >>, <<" .config" >>, <<" .lock" >>,
7980 <<" .c" >>, <<" .cpp" >>, <<" .h" >>, <<" .hpp" >>, <<" .cc" >>]).
8081
81- auto () ->
82+ get_extensions (State ) ->
83+ ExtraExtensions = rebar_state :get (State , extra_extensions , []),
84+ [unicode :characters_to_binary (Ext ) || Ext <- ExtraExtensions ] ++ ? VALID_EXTENSIONS_DEFAULT .
85+
86+ auto (Extensions ) ->
8287 case whereis (rebar_agent ) of
8388 undefined ->
8489 timer :sleep (100 );
@@ -87,7 +92,19 @@ auto() ->
8792 receive
8893 {ChangedFile , _Events } ->
8994 Ext = filename :extension (unicode :characters_to_binary (ChangedFile )),
90- IsValid = lists :member (Ext , ? VALID_EXTENSIONS ),
95+ IsValid = lists :any (
96+ fun (ValidExt ) ->
97+ RE = <<ValidExt /binary , " $" >>,
98+ Result = re :run (Ext , RE ),
99+ case Result of
100+ {match , _Captured } -> true ;
101+ match -> true ;
102+ nomatch -> false ;
103+ {error , _ErrType } -> false
104+ end
105+ end ,
106+ Extensions
107+ ),
91108 case IsValid of
92109 false -> pass ;
93110 true ->
@@ -101,7 +118,7 @@ auto() ->
101118 end
102119
103120 end ,
104- ? MODULE :auto ().
121+ ? MODULE :auto (Extensions ).
105122
106123flush () ->
107124 receive
0 commit comments