Skip to content

Commit

Permalink
Update keys
Browse files Browse the repository at this point in the history
  • Loading branch information
wojtekmach committed May 17, 2024
1 parent c6f63c1 commit bdb442e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/hex/scm.ex
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ defmodule Hex.SCM do
end
end

# https://hexdocs.pm/mix/Mix.Tasks.Deps.html#module-dependency-definition-options
mix_keys = ~w[app env compile optional only targets override manager runtime system_env]a

# https://hex.pm/docs/usage#options
hex_keys = ~w[hex repo organization]a

internal_keys = ~w[dest lock build]a

@allowed_keys mix_keys ++ hex_keys ++ internal_keys

def update(opts) do
Registry.open()

Expand All @@ -125,11 +135,11 @@ defmodule Hex.SCM do
repo = opts[:repo] || "hexpm"
path = cache_path(repo, name, lock.version)

unknown_options = Keyword.keys(opts) -- ~w[hex dest repo lock env build optional]a
unknown_options = Keyword.keys(opts) -- @allowed_keys

if unknown_options != [] do
Hex.Shell.warn(
"The #{name} dependency is using unknown options: " <>
"#{name} is using unknown options: " <>
Enum.map_join(unknown_options, ", ", &inspect/1)
)
end
Expand Down
2 changes: 1 addition & 1 deletion test/hex/mix_task_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -907,7 +907,7 @@ defmodule Hex.MixTaskTest do
["\e[33mex_doc is missing its version requirement, use \">= 0.0.0\"" <> _]}

assert_received {:mix_shell, :info,
["\e[33mex_doc dependency is using unknown options: :dir, :typo\e[0m"]}
["\e[33mex_doc is using unknown options: :dir, :typo\e[0m"]}
end)
end

Expand Down

0 comments on commit bdb442e

Please sign in to comment.