@@ -5,8 +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: [ ]
9
+
10
+ defrecord Project , name: nil , config: nil , rec_enabled?: true , io_done: false
10
11
11
12
def start_link ( env ) do
12
13
:gen_server . start_link ( { :local , __MODULE__ } , __MODULE__ , env , [ ] )
@@ -56,8 +57,8 @@ defmodule Mix.Server do
56
57
57
58
def handle_call ( :pop_project , _from , config ) do
58
59
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 ) }
61
62
_ ->
62
63
{ :reply , nil , config }
63
64
end
@@ -67,15 +68,25 @@ defmodule Mix.Server do
67
68
{ :reply , config . mixfile [ app ] , config }
68
69
end
69
70
70
- def handle_call ( :io_done , _from , config ) do
71
- { :reply , config . io_done , config . io_done ( true ) }
72
- end
73
-
74
71
def handle_call ( :output_app? , _from , config ) do
75
72
# Check that we haven't already outputted app and that we are part of an
76
73
# 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
79
90
end
80
91
81
92
def handle_call ( request , from , config ) do
@@ -106,11 +117,11 @@ defmodule Mix.Server do
106
117
{ :noreply , config . update_tasks Ordset . filter ( fn { t , _ } -> t != task end , & 1 ) }
107
118
end
108
119
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 ]
111
123
config = config . post_config ( [ ] )
112
- . update_projects ( [ { name , project } | & 1 ] )
113
- . io_done ( false )
124
+ . update_projects ( [ project | & 1 ] )
114
125
{ :noreply , config }
115
126
end
116
127
@@ -130,19 +141,31 @@ defmodule Mix.Server do
130
141
{ :noreply , config . mixfile ( [ ] ) }
131
142
end
132
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
+
133
153
def handle_cast ( request , config ) do
134
154
super ( request , config )
135
155
end
136
156
137
- # Returns if project is part of an umbrella project
157
+ # Returns true if project is part of an umbrella project
138
158
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 )
140
162
end
141
163
142
- # Returns if project is an umbrella project
164
+ # Returns true if project is an umbrella project
143
165
defp umbrella? ( config ) do
144
166
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
146
169
_ -> false
147
170
end
148
171
end
0 commit comments