From 72dcd0ac259723a524a83dd79d4dff7f74acdc74 Mon Sep 17 00:00:00 2001 From: alexwl Date: Tue, 26 Mar 2019 17:07:04 +0300 Subject: Update parsePackagesPath so that --package and --packages options can be specified independently --- app/Server.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/Server.hs b/app/Server.hs index 9544539..de2c325 100644 --- a/app/Server.hs +++ b/app/Server.hs @@ -265,8 +265,8 @@ configParser = parsePackagesPath :: Parser FilePath -> Parser [FilePath] -> Parser PackagesPath parsePackagesPath parseDir parsePaths = - (PackagesPath <$> fmap Just parseDir <*> parsePaths) - <|> pure (PackagesPath Nothing ["."]) + PackagesPath <$> optional parseDir <*> (parsePaths <|> pure []) + -------------------------------------------------------------------------------- -- Loading packages @@ -1851,7 +1851,13 @@ application env = serve (Proxy :: Proxy API) (server env) main :: IO () main = do + let addDefaultPath :: ServerConfig -> ServerConfig + addDefaultPath config = + if configPackagesPath config == PackagesPath Nothing [] + then config {configPackagesPath = PackagesPath Nothing ["."]} + else config config <- + addDefaultPath <$> execParser (Options.Applicative.info (configParser <**> helper) @@ -1883,7 +1889,7 @@ main = do loggerMiddleware <- liftIO $ mkRequestLogger - def {outputFormat = Detailed True, destination = Logger loggerSet} + def {outputFormat = Detailed True, destination = Logger loggerSet} let staticFilePrefix = configStaticFilesUrlPrefix config mbJsDistPath = configJsDistDirectory config environment = -- cgit v1.2.3