Skip to content

Commit 02a3bac

Browse files
authored
Return nothing if tool is not on the PATH (#309)
1 parent 0b12fcb commit 02a3bac

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/Ide/Version.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import qualified Paths_haskell_language_server as Meta
1313
import System.Info
1414
import Data.Version
1515
import Data.Maybe (listToMaybe)
16+
import System.Directory
1617
import System.Process
1718
import System.Exit
1819
import Text.ParserCombinators.ReadP
@@ -60,10 +61,12 @@ findProgramVersions = ProgramsOfInterest
6061
-- If the invocation has a non-zero exit-code, we return 'Nothing'
6162
findVersionOf :: FilePath -> IO (Maybe Version)
6263
findVersionOf tool =
63-
readProcessWithExitCode tool ["--numeric-version"] "" >>= \case
64-
(ExitSuccess, sout, _) -> pure $ consumeParser myVersionParser sout
65-
_ -> pure $ Nothing
66-
64+
findExecutable tool >>= \case
65+
Nothing -> pure Nothing
66+
Just path ->
67+
readProcessWithExitCode path ["--numeric-version"] "" >>= \case
68+
(ExitSuccess, sout, _) -> pure $ consumeParser myVersionParser sout
69+
_ -> pure $ Nothing
6770
where
6871
myVersionParser = do
6972
skipSpaces

0 commit comments

Comments
 (0)