@@ -38,10 +38,9 @@ hlsVersion =
3838 hlsGhcDisplayVersion = compilerName ++ " -" ++ VERSION_ghc
3939
4040data ProgramsOfInterest = ProgramsOfInterest
41- { cabalVersion :: Maybe Version
42- , stackVersion :: Maybe Version
43- , ghcVersion :: Maybe Version
44- , stackGhcVersion :: Maybe Version
41+ { cabalVersion :: Maybe Version
42+ , stackVersion :: Maybe Version
43+ , ghcVersion :: Maybe Version
4544 }
4645
4746showProgramVersionOfInterest :: ProgramsOfInterest -> String
@@ -50,27 +49,26 @@ showProgramVersionOfInterest ProgramsOfInterest {..} =
5049 [ " cabal:\t\t " ++ showVersionWithDefault cabalVersion
5150 , " stack:\t\t " ++ showVersionWithDefault stackVersion
5251 , " ghc:\t\t " ++ showVersionWithDefault ghcVersion
53- , " stack ghc:\t " ++ showVersionWithDefault stackGhcVersion
5452 ]
5553 where
5654 showVersionWithDefault :: Maybe Version -> String
5755 showVersionWithDefault = maybe " Not found" showVersion
5856
5957findProgramVersions :: IO ProgramsOfInterest
6058findProgramVersions = ProgramsOfInterest
61- <$> findVersionOf " cabal" [" --numeric-version" ]
62- <*> findVersionOf " stack" [" --numeric-version" ]
63- <*> findVersionOf " ghc" [" --numeric-version" ]
64- <*> findVersionOf " stack" [" ghc" , " --" , " --numeric-version" ]
59+ <$> findVersionOf " cabal"
60+ <*> findVersionOf " stack"
61+ <*> findVersionOf " ghc"
6562
6663-- | Find the version of the given program.
64+ -- Assumes the program accepts the cli argument "--numeric-version".
6765-- If the invocation has a non-zero exit-code, we return 'Nothing'
68- findVersionOf :: FilePath -> [ String ] -> IO (Maybe Version )
69- findVersionOf tool args =
66+ findVersionOf :: FilePath -> IO (Maybe Version )
67+ findVersionOf tool =
7068 findExecutable tool >>= \ case
7169 Nothing -> pure Nothing
7270 Just path ->
73- readProcessWithExitCode path args " " >>= \ case
71+ readProcessWithExitCode path [ " --numeric-version " ] " " >>= \ case
7472 (ExitSuccess , sout, _) -> pure $ consumeParser myVersionParser sout
7573 _ -> pure Nothing
7674 where
0 commit comments