@@ -5,10 +5,9 @@ defmodule Mix.Server do
5
5
use GenServer.Behaviour
6
6
7
7
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: [ ]
10
9
11
- defrecord Project , name: nil , config: nil
10
+ defrecord Project , name: nil , config: nil , rec_enabled?: true , io_done: false
12
11
13
12
def start_link ( env ) do
14
13
:gen_server . start_link ( { :local , __MODULE__ } , __MODULE__ , env , [ ] )
@@ -59,7 +58,7 @@ defmodule Mix.Server do
59
58
def handle_call ( :pop_project , _from , config ) do
60
59
case config . projects do
61
60
[ Project [ name : project ] | tail ] ->
62
- { :reply , project , config . projects ( tail ) . io_done ( false ) }
61
+ { :reply , project , config . projects ( tail ) }
63
62
_ ->
64
63
{ :reply , nil , config }
65
64
end
@@ -69,15 +68,25 @@ defmodule Mix.Server do
69
68
{ :reply , config . mixfile [ app ] , config }
70
69
end
71
70
72
- def handle_call ( :io_done , _from , config ) do
73
- { :reply , config . io_done , config . io_done ( true ) }
74
- end
75
-
76
71
def handle_call ( :output_app? , _from , config ) do
77
72
# Check that we haven't already outputted app and that we are part of an
78
73
# umbrella project
79
- output = not config . io_done and not umbrella? ( config ) and in_umbrella? ( config )
80
- { :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
81
90
end
82
91
83
92
def handle_call ( request , from , config ) do
@@ -113,7 +122,6 @@ defmodule Mix.Server do
113
122
project = Project [ name : name , config: conf ]
114
123
config = config . post_config ( [ ] )
115
124
. update_projects ( [ project | & 1 ] )
116
- . io_done ( false )
117
125
{ :noreply , config }
118
126
end
119
127
@@ -133,18 +141,27 @@ defmodule Mix.Server do
133
141
{ :noreply , config . mixfile ( [ ] ) }
134
142
end
135
143
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
+
136
153
def handle_cast ( request , config ) do
137
154
super ( request , config )
138
155
end
139
156
140
- # Returns if project is part of an umbrella project
157
+ # Returns true if project is part of an umbrella project
141
158
defp in_umbrella? ( config ) do
142
159
Enum . any? ( config . projects , fn ( Project [ config : conf ] ) ->
143
160
conf [ :apps_path ] != nil
144
161
end )
145
162
end
146
163
147
- # Returns if project is an umbrella project
164
+ # Returns true if project is an umbrella project
148
165
defp umbrella? ( config ) do
149
166
case config . projects do
150
167
[ Project [ name : name , config: config ] | _ ] when name != nil ->
0 commit comments