Also check for GHC and Cabal updates on start

This commit is contained in:
Julian Ospald 2020-04-18 20:20:18 +02:00
parent 72bcfa9270
commit 5d94d0bf75
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 23 additions and 1 deletions

View File

@ -46,6 +46,7 @@ import Language.Haskell.TH
import Options.Applicative hiding ( style )
import Options.Applicative.Help.Pretty ( text )
import Prelude hiding ( appendFile )
import Safe
import System.Console.Pretty
import System.Environment
import System.Exit
@ -1030,7 +1031,9 @@ printListResult lr = do
putStrLn $ formatted
checkForUpdates :: (MonadFail m, MonadLogger m) => GHCupDownloads -> m ()
checkForUpdates :: (MonadIO m, MonadFail m, MonadLogger m)
=> GHCupDownloads
-> m ()
checkForUpdates dls = do
forM_ (getLatest dls GHCup) $ \l -> do
(Right ghc_ver) <- pure $ version $ prettyPVP ghcUpVer
@ -1038,6 +1041,24 @@ checkForUpdates dls = do
$ $(logWarn)
[i|New GHCup version available: #{prettyVer l}. To upgrade, run 'ghcup upgrade'|]
forM_ (getLatest dls GHC) $ \l -> do
mghc_ver <- latestInstalled GHC
forM mghc_ver $ \ghc_ver ->
when (l > ghc_ver)
$ $(logWarn)
[i|New GHC version available: #{prettyVer l}. To upgrade, run 'ghcup install #{prettyVer l}'|]
forM_ (getLatest dls Cabal) $ \l -> do
mcabal_ver <- latestInstalled Cabal
forM mcabal_ver $ \cabal_ver ->
when (l > cabal_ver)
$ $(logWarn)
[i|New Cabal version available: #{prettyVer l}. To upgrade, run 'ghcup install-cabal #{prettyVer l}'|]
where
latestInstalled tool = (fmap lVer . lastMay)
<$> liftIO (listVersions dls (Just tool) (Just ListInstalled))
prettyDebugInfo :: DebugInfo -> String
prettyDebugInfo DebugInfo {..} = [i|Debug Info

View File

@ -326,6 +326,7 @@ executable ghcup
, optparse-applicative
, pretty-terminal
, resourcet
, safe
, string-interpolate
, table-layout
, template-haskell