Skip to content

Commit

Permalink
Change hex.publish --no-confirm to --yes
Browse files Browse the repository at this point in the history
  • Loading branch information
ericmj committed Jul 3, 2018
1 parent 5497066 commit bc0386f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
36 changes: 15 additions & 21 deletions lib/mix/tasks/hex.publish.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ defmodule Mix.Tasks.Hex.Publish do
* `--revert VERSION` - Revert given version, if the last version is reverted
the package is removed
* `--organization ORGANIZATION` - The organization the package belongs to
* `--no-confirm` - Disables confirmation message before publishing
* `--yes` - Publishes the package without any confirmation prompts
## Configuration
Expand Down Expand Up @@ -93,7 +93,7 @@ defmodule Mix.Tasks.Hex.Publish do
canonical: :string,
organization: :string,
organisation: :string,
confirm: :boolean
yes: :boolean
]

def run(args) do
Expand Down Expand Up @@ -194,7 +194,7 @@ defmodule Mix.Tasks.Hex.Publish do
end

defp proceed?(build, organization, opts) do
confirm? = Keyword.get(opts, :confirm, true)
yes? = Keyword.get(opts, :yes, false)
meta = build.meta
exclude_deps = build.exclude_deps
package = build.package
Expand All @@ -204,25 +204,19 @@ defmodule Mix.Tasks.Hex.Publish do

print_link_to_coc()

cond do
not confirm? ->
true

organization in [nil, "hexpm"] ->
Hex.Shell.info(["Publishing package to ", emphasis("public"), " repository hexpm."])
Hex.Shell.yes?("Proceed?")

true ->
Hex.Shell.info([
[
"Publishing package to ",
emphasis("private"),
" repository #{organization}."
]
])

Hex.Shell.yes?("Proceed?")
if organization in [nil, "hexpm"] do
Hex.Shell.info(["Publishing package to ", emphasis("public"), " repository hexpm."])
else
Hex.Shell.info([
[
"Publishing package to ",
emphasis("private"),
" repository #{organization}."
]
])
end

yes? or Hex.Shell.yes?("Proceed?")
end

defp emphasis(text) do
Expand Down
6 changes: 3 additions & 3 deletions test/mix/tasks/hex.publish_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ defmodule Mix.Tasks.Hex.PublishTest do
setup_auth("user", "hunter42")
# note that we don't need the yes? input here
send(self(), {:mix_shell_input, :prompt, "hunter42"})
Mix.Tasks.Hex.Publish.run(["package", "--no-progress", "--no-confirm"])
Mix.Tasks.Hex.Publish.run(["package", "--no-progress", "--yes"])
assert {:ok, {200, _, _}} = Hex.API.Release.get("hexpm", "release_a", "0.0.1")
end)
after
Expand Down Expand Up @@ -158,7 +158,7 @@ defmodule Mix.Tasks.Hex.PublishTest do
setup_auth("user", "hunter42")

send(self(), {:mix_shell_input, :prompt, "hunter42"})
Mix.Tasks.Hex.Publish.run(["--no-progress", "--no-confirm"])
Mix.Tasks.Hex.Publish.run(["--no-progress", "--yes"])
message = "Building released_name 0.0.1"
assert_received {:mix_shell, :info, [^message]}

Expand Down Expand Up @@ -198,7 +198,7 @@ defmodule Mix.Tasks.Hex.PublishTest do
assert_received {:mix_shell, :info, [key]}

Hex.State.put(:api_key_write_unencrypted, key)
Mix.Tasks.Hex.Publish.run(["package", "--no-confirm", "--no-progress"])
Mix.Tasks.Hex.Publish.run(["package", "--yes", "--no-progress"])

message = "Building release_a 0.0.1"
assert_received {:mix_shell, :info, [^message]}
Expand Down

0 comments on commit bc0386f

Please sign in to comment.