Skip to content

Minor refactors in UpdateVersions.purs #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/update.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions src/Setup/UpdateVersions.purs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import Data.Argonaut.Encode ((:=), (~>))
import Data.Array (foldl)
import Data.Array as Array
import Data.Either (Either(..), hush)
import Data.Foldable (fold)
import Data.Foldable (fold, maximum)
import Data.Int (toNumber)
import Data.Maybe (Maybe(..), fromMaybe, isNothing)
import Data.String as String
Expand Down Expand Up @@ -128,9 +128,9 @@ fetchLatestReleaseVersion tool = Tool.repository tool # case tool of
, printJsonDecodeError e
]
Right isDraft ->
if isDraft
then pure Nothing
else pure (Just version)
pure if isDraft
then Nothing
else Just version

tagStrToVersion tagStr =
tagStr
Expand Down Expand Up @@ -158,10 +158,9 @@ fetchLatestReleaseVersion tool = Tool.repository tool # case tool of

Right arr -> do
let
tags = Array.catMaybes $ map (tagStrToVersion >>> hush) arr
sorted = Array.reverse $ Array.sort tags
tags = Array.mapMaybe (tagStrToVersion >>> hush) arr

case Array.head sorted of
case maximum tags of
Nothing ->
throwError $ error "Could not download latest release version."

Expand Down