Skip to content

Commit 54988ae

Browse files
committed
Fix mix function names and docs
1 parent dd9ba46 commit 54988ae

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

lib/mix/lib/mix/deps.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ defmodule Mix.Deps do
174174
"""
175175
def compile_paths(Mix.Dep[app: app, opts: opts] = dep) do
176176
if mix?(dep) do
177-
Mix.Project.for_project app, opts[:dest], fn _ ->
177+
Mix.Project.in_project app, opts[:dest], fn _ ->
178178
Mix.Project.compile_paths
179179
end
180180
else
@@ -187,7 +187,7 @@ defmodule Mix.Deps do
187187
"""
188188
def load_paths(Mix.Dep[app: app, opts: opts] = dep) do
189189
if mix?(dep) do
190-
paths = Mix.Project.for_project app, opts[:dest], fn _ ->
190+
paths = Mix.Project.in_project app, opts[:dest], fn _ ->
191191
Mix.Project.load_paths
192192
end
193193
Enum.uniq paths
@@ -200,7 +200,7 @@ defmodule Mix.Deps do
200200
Returns if dependency is a mix project.
201201
"""
202202
def mix?(dep) do
203-
File.regular? Path.join(dep.opts[:dest], "mix.exs")
203+
dep.project != nil
204204
end
205205

206206
@doc """

lib/mix/lib/mix/project.ex

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,26 +184,27 @@ defmodule Mix.Project do
184184
end
185185

186186
projects = topsort_projects(projects)
187-
old_tasks = Mix.Task.clear
188187
results = Enum.map projects, fn { app, app_path } ->
189-
for_project(app, app_path, fun)
188+
in_project(app, app_path, fun)
190189
end
191190

192-
Mix.Task.set_tasks(old_tasks)
193191
results
194192
end
195193

196194
@doc """
197-
Run fun with project app on top of the stack.
195+
Run fun in the context of project app and working directory app_path.
196+
Optionally takes a post_config.
198197
"""
199-
def for_project(app, app_path, fun) do
198+
def in_project(app, app_path, post_config // [], fun) do
200199
umbrella_path = apps_path
201200

202201
File.cd! app_path, fn ->
203-
Mix.Project.load_project(app)
204-
result = fun.(umbrella_path)
205-
Mix.Project.pop
206-
Mix.Task.clear
202+
load_project(app, post_config)
203+
result = try do
204+
fun.(umbrella_path)
205+
after
206+
Mix.Project.pop
207+
end
207208
result
208209
end
209210
end
@@ -240,7 +241,7 @@ defmodule Mix.Project do
240241
end
241242

242243
Enum.each projects, fn { app, app_path } ->
243-
for_project app, app_path, fn apps_path ->
244+
in_project app, app_path, fn apps_path ->
244245
Enum.each Mix.Deps.children, fn dep ->
245246
if Mix.Deps.available?(dep) and Mix.Deps.in_umbrella?(dep, apps_path) do
246247
:digraph.add_edge(graph, dep.app, app)

lib/mix/lib/mix/server.ex

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ defmodule Mix.Server do
7474
def handle_call(:output_app?, _from, config) do
7575
# Check that we haven't already outputted app and that we are part of an
7676
# umbrella project
77-
umbrella = case config.projects do
78-
[{ h, conf }|_] when h != nil -> conf[:apps_path] != nil
79-
_ -> false
80-
end
81-
in_umbrella = Enum.any?(config.projects, fn { _, conf } -> conf[:apps_path] != nil end)
82-
output = !config.io_done && !umbrella && in_umbrella
83-
77+
output = not config.io_done and not umbrella?(config) and in_umbrella?(config)
8478
{ :reply, output, config.io_done(true) }
8579
end
8680

@@ -139,4 +133,17 @@ defmodule Mix.Server do
139133
def handle_cast(request, config) do
140134
super(request, config)
141135
end
136+
137+
# Returns if project is part of an umbrella project
138+
defp in_umbrella?(config) do
139+
Enum.any? config.projects, fn { _, conf } -> conf[:apps_path] != nil end
140+
end
141+
142+
# Returns if project is an umbrella project
143+
defp umbrella?(config) do
144+
case config.projects do
145+
[ { h, conf } | _ ] when h != nil -> conf[:apps_path] != nil
146+
_ -> false
147+
end
148+
end
142149
end

0 commit comments

Comments
 (0)