Skip to content

Add --no-load-deps flag to deps.loadpaths task #8256

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions lib/mix/lib/mix/tasks/deps.loadpaths.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ defmodule Mix.Tasks.Deps.Loadpaths do

* `--no-deps-check` - does not check or compile deps, only load available ones
* `--no-compile` - does not compile dependencies
* `--no-load-deps` - do not load deps from the code path

"""

Expand All @@ -26,14 +27,16 @@ defmodule Mix.Tasks.Deps.Loadpaths do
deps_check(all, "--no-compile" in args)
end

load_paths =
for dep <- all,
path <- Mix.Dep.load_paths(dep) do
_ = Code.prepend_path(path)
path
end
unless "--no-load-deps" in args do
load_paths =
for dep <- all,
path <- Mix.Dep.load_paths(dep) do
_ = Code.prepend_path(path)
path
end

prune_deps(load_paths, "--no-deps-check" in args)
prune_deps(load_paths, "--no-deps-check" in args)
end
end

# If the build is per environment, we should be able to look
Expand Down
30 changes: 30 additions & 0 deletions lib/mix/test/mix/tasks/deps_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,36 @@ defmodule Mix.Tasks.DepsTest do
end)
end

test "does not load or prune builds with --no-load-deps" do
Mix.Project.push(SuccessfulDepsApp)

in_fixture("deps_status", fn ->
# Start from scratch!
File.rm_rf("_build")

Mix.Tasks.Deps.Compile.run([])
Mix.Tasks.Deps.Loadpaths.run([])
assert File.exists?("_build/dev/lib/ok/ebin/ok.app")
assert File.exists?("_build/dev/lib/ok/priv/sample")

Mix.Tasks.Compile.run([])
assert to_charlist(Path.expand("_build/dev/lib/ok/ebin/")) in :code.get_path()
assert File.exists?("_build/dev/lib/sample/ebin/sample.app")

# Remove the deps without build_path
Mix.ProjectStack.post_config(deps: [])
Mix.ProjectStack.clear_cache()
Mix.Project.pop()
Mix.Project.push(SuccessfulDepsApp)
Code.delete_path("_build/dev/lib/ok/ebin")

Mix.Tasks.Deps.Loadpaths.run(["--no-load-deps"])
refute to_charlist(Path.expand("_build/dev/lib/ok/ebin/")) in :code.get_path()
assert File.exists?("_build/dev/lib/ok/ebin/ok.app")
assert File.exists?("_build/dev/lib/sample/ebin/sample.app")
end)
end

## deps.unlock

test "unlocks all deps", context do
Expand Down