Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
Use case instead of with
Browse files Browse the repository at this point in the history
  • Loading branch information
karol-t-wilk committed Mar 6, 2024
1 parent d882dfc commit 0e968c1
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/mix/tasks/search/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ defmodule Mix.Tasks.Search.Index do
{:ok, releases} = Search.HexClient.get_releases(package)

release =
with [version] <- args_tail,
{:ok, version} = Version.parse(version) do
Enum.find(releases, &(&1.version == version))
else
[] -> Enum.max_by(releases, & &1.version, Version, fn -> nil end)
case args_tail do
[version] ->
version = Version.parse!(version)
Enum.find(releases, &(&1.version == version))

[] ->
Enum.max_by(releases, & &1.version, Version, fn -> nil end)
end

if release do
Expand Down

0 comments on commit 0e968c1

Please sign in to comment.