Skip to content

Return nothing if tool is not on the PATH #309

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
Aug 11, 2020
Merged
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
11 changes: 7 additions & 4 deletions src/Ide/Version.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import qualified Paths_haskell_language_server as Meta
import System.Info
import Data.Version
import Data.Maybe (listToMaybe)
import System.Directory
import System.Process
import System.Exit
import Text.ParserCombinators.ReadP
Expand Down Expand Up @@ -60,10 +61,12 @@ findProgramVersions = ProgramsOfInterest
-- If the invocation has a non-zero exit-code, we return 'Nothing'
findVersionOf :: FilePath -> IO (Maybe Version)
findVersionOf tool =
readProcessWithExitCode tool ["--numeric-version"] "" >>= \case
(ExitSuccess, sout, _) -> pure $ consumeParser myVersionParser sout
_ -> pure $ Nothing

findExecutable tool >>= \case
Nothing -> pure Nothing
Just path ->
readProcessWithExitCode path ["--numeric-version"] "" >>= \case
(ExitSuccess, sout, _) -> pure $ consumeParser myVersionParser sout
_ -> pure $ Nothing
where
myVersionParser = do
skipSpaces
Expand Down