File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -326,13 +326,20 @@ makeAbsolute = fmap FP.normalise . absolutize
326326--
327327-- Throws a 'ReadProcessException' if unsuccessful.
328328findExecutable :: (MonadIO m , MonadThrow n ) => EnvOverride -> String -> m (n (Path Abs File ))
329- findExecutable _ name | any FP. isPathSeparator name = do
330- exists <- liftIO $ doesFileExist name
331- if exists
332- then do
333- path <- liftIO $ parseRelAsAbsFile name
334- return $ return path
335- else return $ throwM $ ExecutableNotFoundAt name
329+ findExecutable eo name0 | any FP. isPathSeparator name0 = do
330+ let names0
331+ | null (eoExeExtension eo) = [name0]
332+ -- Support `stack exec foo/bar.exe` on Windows
333+ | otherwise = [name0 ++ eoExeExtension eo, name0]
334+ testNames [] = return $ throwM $ ExecutableNotFoundAt name0
335+ testNames (name: names) = do
336+ exists <- liftIO $ doesFileExist name
337+ if exists
338+ then do
339+ path <- liftIO $ parseRelAsAbsFile name
340+ return $ return path
341+ else testNames names
342+ testNames names0
336343findExecutable eo name = liftIO $ do
337344 m <- readIORef $ eoExeCache eo
338345 epath <- case Map. lookup name m of
You can’t perform that action at this time.
0 commit comments