Skip to content

Commit

Permalink
Do not fetch artifacts on deps.get that are set in the env
Browse files Browse the repository at this point in the history
  • Loading branch information
mobileoverlord committed Jun 4, 2018
1 parent 742fa97 commit ad8f9dd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/mix/tasks/nerves.artifact.get.ex
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,20 @@ defmodule Mix.Tasks.Nerves.Artifact.Get do
:noop

%Nerves.Package{} = pkg ->
case Artifact.Cache.get(pkg) do
nil ->
get_artifact(pkg)

_cache_path ->
Nerves.Utils.Shell.success(" Cached #{app}")
# Check to see if the package path is set in the environment
if Nerves.Artifact.env_var?(pkg) do
path = System.get_env(Nerves.Artifact.env_var(pkg))
Nerves.Utils.Shell.success(" Env #{app}")
Nerves.Utils.Shell.success(" #{path}")
else
# Check the cache
case Artifact.Cache.get(pkg) do
nil ->
get_artifact(pkg)

_cache_path ->
Nerves.Utils.Shell.success(" Cached #{app}")
end
end

_ ->
Expand Down
18 changes: 18 additions & 0 deletions test/nerves/cache_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,22 @@ defmodule Nerves.CacheTest do
refute File.exists?(dl_path)
end)
end

test "skip fetching packages that have paths set in the env" do
in_fixture("system", fn ->
File.cwd!()
|> Path.join("mix.exs")
|> Code.require_file()

Nerves.Env.start()

File.mkdir_p(Nerves.Env.download_dir())

System.put_env("NERVES_SYSTEM", Nerves.Env.download_dir())
Mix.Tasks.Nerves.Artifact.Get.get(:system, [])
message = "\e[32m " <> Nerves.Env.download_dir() <> "\e[0m"
assert_receive({:mix_shell, :info, [^message]}, 100)
System.delete_env("NERVES_SYSTEM")
end)
end
end

0 comments on commit ad8f9dd

Please sign in to comment.