-- | Determine the absolute path to an executable on the PATH.
--
-- Throws a 'JupyterKernelspecException' if the the executable cannot be found.
which :: FilePath -> IO FilePath
which cmd = do
  mPath <- findExecutable cmd
  case mPath of
    Just path -> canonicalizePath path
    Nothing ->
      installFailed $ "Could not find '" ++
                      cmd ++
                      "' command on system PATH; please install it."

-- | Verify that a proper version of Jupyter is installed.
--
-- Throws a 'JupyterKernelspecException' if @jupyter@ is not present, is an incompatible version, or
-- otherwise cannot be used with this library.
which :: FilePath -> IO FilePath
which cmd = do
  mPath <- findExecutable cmd
  case mPath of
    Just path -> canonicalizePath path
    Nothing ->
      installFailed $ "Could not find '" ++
                      cmd ++
                      "' command on system PATH; please install it."

-- | Verify that a proper version of Jupyter is installed.
--
-- Throws a 'JupyterKernelspecException' if @jupyter@ is not present, is an incompatible version, or
-- otherwise cannot be used with this library.
which cmd = do
  mPath <- findExecutable cmd
  case mPath of
    Just path -> canonicalizePath path
    Nothing ->
      installFailed $ "Could not find '" ++
                      cmd ++
                      "' command on system PATH; please install it."

-- | Verify that a proper version of Jupyter is installed.
--
-- Throws a 'JupyterKernelspecException' if @jupyter@ is not present, is an incompatible version, or
-- otherwise cannot be used with this library.