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 @@ -294,13 +294,20 @@ findExecutable eo name = liftIO $ do
294294 Nothing -> do
295295 let loop [] = return $ Left $ ExecutableNotFound name (eoPath eo)
296296 loop (dir: dirs) = do
297- let fp = dir FP. </> name ++ eoExeExtension eo
298- exists <- doesFileExist fp
299- if exists
300- then do
301- fp' <- makeAbsolute fp >>= parseAbsFile
302- return $ return fp'
303- else loop dirs
297+ let fp0 = dir FP. </> name
298+ fps0
299+ | null (eoExeExtension eo) = [fp0]
300+ -- Support `stack exec foo.exe` on Windows
301+ | otherwise = [fp0 ++ eoExeExtension eo, fp0]
302+ testFPs [] = loop dirs
303+ testFPs (fp: fps) = do
304+ exists <- doesFileExist fp
305+ if exists
306+ then do
307+ fp' <- makeAbsolute fp >>= parseAbsFile
308+ return $ return fp'
309+ else testFPs fps
310+ testFPs fps0
304311 epath <- loop $ eoPath eo
305312 ! () <- atomicModifyIORef (eoExeCache eo) $ \ m' ->
306313 (Map. insert name epath m', () )
You can’t perform that action at this time.
0 commit comments