diff options
author | alexwl <alexey.a.kiryushin@gmail.com> | 2019-03-26 17:07:04 +0300 |
---|---|---|
committer | alexwl <alexey.a.kiryushin@gmail.com> | 2019-03-26 17:07:04 +0300 |
commit | 72dcd0ac259723a524a83dd79d4dff7f74acdc74 (patch) | |
tree | 4402dee3b40bf7102ad284816536b642fa7c4894 | |
parent | 3bff037c1f36078c8543983e0d87731e8d073bc4 (diff) |
Update parsePackagesPath so that --package and --packages options can be specified independently
-rw-r--r-- | app/Server.hs | 12 |
1 files changed, 9 insertions, 3 deletions
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 = |