Skip to content

Commit 53aeb26

Browse files
author
José Valim
committed
Merge pull request #2741 from styx/master
Fixes #2737
2 parents 035d822 + bba0d12 commit 53aeb26

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/mix/lib/mix/tasks/deps.unlock.ex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ defmodule Mix.Tasks.Deps.Unlock do
3131

3232
apps != [] ->
3333
lock =
34-
Enum.reduce apps, Mix.Dep.Lock.read, fn(app, lock) ->
35-
Map.delete(lock, String.to_atom(app))
34+
Enum.reduce apps, Mix.Dep.Lock.read, fn(app_str, lock) ->
35+
app = String.to_atom(app_str)
36+
if Map.has_key?(lock, app) do
37+
Map.delete(lock, app)
38+
else
39+
Mix.shell.error "warning: #{app} dependency is not locked"
40+
lock
41+
end
3642
end
3743
Mix.Dep.Lock.write(lock)
3844

lib/mix/test/mix/tasks/deps_test.exs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ defmodule Mix.Tasks.DepsTest do
199199
Mix.Dep.Lock.write %{git_repo: "abcdef", another: "hash"}
200200
Mix.Tasks.Deps.Unlock.run ["git_repo", "unknown"]
201201
assert Mix.Dep.Lock.read == %{another: "hash"}
202+
error = "warning: unknown dependency is not locked"
203+
assert_received {:mix_shell, :error, [^error]}
202204
end
203205
end
204206

0 commit comments

Comments
 (0)