Skip to content

Commit 47368dd

Browse files
committed
Allow mixing local with and without paths when generating
1 parent 8149c93 commit 47368dd

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/Action/Generate.hs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,20 @@ actionGenerate g@Generate{..} = withTiming (if debug then Just $ replaceExtensio
238238
warnFlagIgnored "--haddock" "set" (local_ /= []) "--local"
239239
warnFlagIgnored "--haddock" "set" (isJust download) "--download"
240240
readHaskellHaddock timing settings dir
241-
| [""] <- local_ -> do
242-
warnFlagIgnored "--local" "used as flag (no paths)" (isJust download) "--download"
243-
readHaskellGhcpkg timing settings
244241
| [] <- local_ -> do readHaskellOnline timing settings doDownload
245-
| otherwise -> readHaskellDirs timing settings local_
242+
| otherwise -> do
243+
let (localFlag, dirs) = partition (=="") local_
244+
(ghcPkgCbl, ghcPkgWant, ghcPkgSource) <-
245+
if null localFlag
246+
then pure (Map.empty, Set.empty, pure ())
247+
else do
248+
warnFlagIgnored "--local" "used as flag (no paths)" (isJust download) "--download"
249+
readHaskellGhcpkg timing settings
250+
(dirsCbl, dirsWant, dirsSource) <-
251+
if null dirs
252+
then pure (Map.empty, Set.empty, pure ())
253+
else readHaskellDirs timing settings dirs
254+
pure (Map.union dirsCbl ghcPkgCbl, Set.union dirsWant ghcPkgWant, ghcPkgSource >> dirsSource)
246255
Frege | [] <- local_ -> readFregeOnline timing doDownload
247256
| otherwise -> errorIO "No support for local Frege databases"
248257
(cblErrs, popularity) <- evaluate $ packagePopularity cbl

0 commit comments

Comments
 (0)