@@ -5,8 +5,9 @@ defmodule Mix.Server do
55 use GenServer.Behaviour
66
77 defrecord Config , tasks: Ordset . new , projects: [ ] , mixfile: [ ] ,
8- shell: Mix.Shell.IO , scm: Ordset . new , env: nil , post_config: [ ] ,
9- io_done: false
8+ shell: Mix.Shell.IO , scm: Ordset . new , env: nil , post_config: [ ]
9+
10+ defrecord Project , name: nil , config: nil , rec_enabled?: true , io_done: false
1011
1112 def start_link ( env ) do
1213 :gen_server . start_link ( { :local , __MODULE__ } , __MODULE__ , env , [ ] )
@@ -56,8 +57,8 @@ defmodule Mix.Server do
5657
5758 def handle_call ( :pop_project , _from , config ) do
5859 case config . projects do
59- [ { project , _ } | tail ] ->
60- { :reply , project , config . projects ( tail ) . io_done ( false ) }
60+ [ Project [ name : project ] | tail ] ->
61+ { :reply , project , config . projects ( tail ) }
6162 _ ->
6263 { :reply , nil , config }
6364 end
@@ -67,15 +68,25 @@ defmodule Mix.Server do
6768 { :reply , config . mixfile [ app ] , config }
6869 end
6970
70- def handle_call ( :io_done , _from , config ) do
71- { :reply , config . io_done , config . io_done ( true ) }
72- end
73-
7471 def handle_call ( :output_app? , _from , config ) do
7572 # Check that we haven't already outputted app and that we are part of an
7673 # umbrella project
77- output = not config . io_done and not umbrella? ( config ) and in_umbrella? ( config )
78- { :reply , output , config . io_done ( true ) }
74+ case config . projects do
75+ [ project | tail ] ->
76+ output = not project . io_done and not umbrella? ( config ) and in_umbrella? ( config )
77+ { :reply , output , config . projects ( [ project . io_done ( true ) | tail ] ) }
78+ _ ->
79+ { :reply , false , config }
80+ end
81+ end
82+
83+ def handle_call ( :recursive_enabled? , _from , config ) do
84+ case config . projects do
85+ [ Project [ rec_enabled? : bool ] | _ ] ->
86+ { :reply , bool , config }
87+ _ ->
88+ { :reply , true , config }
89+ end
7990 end
8091
8192 def handle_call ( request , from , config ) do
@@ -106,11 +117,11 @@ defmodule Mix.Server do
106117 { :noreply , config . update_tasks Ordset . filter ( fn { t , _ } -> t != task end , & 1 ) }
107118 end
108119
109- def handle_cast ( { :push_project , name , project } , config ) do
110- project = Keyword . merge ( project , config . post_config )
120+ def handle_cast ( { :push_project , name , conf } , config ) do
121+ conf = Keyword . merge ( conf , config . post_config )
122+ project = Project [ name : name , config: conf ]
111123 config = config . post_config ( [ ] )
112- . update_projects ( [ { name , project } | & 1 ] )
113- . io_done ( false )
124+ . update_projects ( [ project | & 1 ] )
114125 { :noreply , config }
115126 end
116127
@@ -130,19 +141,31 @@ defmodule Mix.Server do
130141 { :noreply , config . mixfile ( [ ] ) }
131142 end
132143
144+ def handle_cast ( { :recursive_enabled? , bool } , config ) do
145+ case config . projects do
146+ [ project | tail ] ->
147+ { :noreply , config . projects ( [ project . rec_enabled? ( bool ) | tail ] ) }
148+ _ ->
149+ { :noreply , config }
150+ end
151+ end
152+
133153 def handle_cast ( request , config ) do
134154 super ( request , config )
135155 end
136156
137- # Returns if project is part of an umbrella project
157+ # Returns true if project is part of an umbrella project
138158 defp in_umbrella? ( config ) do
139- Enum . any? config . projects , fn { _ , conf } -> conf [ :apps_path ] != nil end
159+ Enum . any? ( config . projects , fn ( Project [ config : conf ] ) ->
160+ conf [ :apps_path ] != nil
161+ end )
140162 end
141163
142- # Returns if project is an umbrella project
164+ # Returns true if project is an umbrella project
143165 defp umbrella? ( config ) do
144166 case config . projects do
145- [ { h , conf } | _ ] when h != nil -> conf [ :apps_path ] != nil
167+ [ Project [ name : name , config: config ] | _ ] when name != nil ->
168+ config [ :apps_path ] != nil
146169 _ -> false
147170 end
148171 end
0 commit comments