packages feed

autoexporter 1.0.0 → 1.1.0

raw patch · 5 files changed

+42/−11 lines, 5 filesdep ~basedep ~directoryPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base, directory

API changes (from Hackage documentation)

+ Autoexporter: ExportScopeDeep :: ExportScope
+ Autoexporter: ExportScopeShallow :: ExportScope
+ Autoexporter: data ExportScope
+ Autoexporter: findFiles :: ExportScope -> FilePath -> IO [FilePath]
+ Autoexporter: findFilesDeep :: FilePath -> IO [FilePath]
- Autoexporter: autoexport :: String -> FilePath -> FilePath -> IO ()
+ Autoexporter: autoexport :: ExportScope -> String -> FilePath -> FilePath -> IO ()

Files

README.markdown view
@@ -54,10 +54,15 @@ Autoexporter will generally behave as you'd expect, but there are a couple things to look out for: -- Only immediate children will be re-exported. If you use this in some module-  `M`, it won't pull in `M.A.B`.- - You cannot selectively include or exclude any modules.++- By default, only immediate children will be re-exported. If you use this in+  some module `M`, it won't pull in `M.A.B`. If you need deep re-exporting,+  please pass `--deep` to Autoexporter like this:++```haskell+{-# OPTIONS_GHC -F -pgmF autoexporter -optF --deep #-}+```  [Autoexporter]: https://github.com/tfausak/autoexporter [Version badge]: https://www.stackage.org/package/autoexporter/badge/nightly?label=version
autoexporter.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.15.0.+-- This file has been generated from package.yaml by hpack version 0.17.0. -- -- see: https://github.com/sol/hpack  name:           autoexporter-version:        1.0.0+version:        1.1.0 synopsis:       Automatically re-export modules. description:    Autoexporter automatically re-exports modules. category:       Utility
package.yaml view
@@ -27,4 +27,4 @@ maintainer: Taylor Fausak name: autoexporter synopsis: Automatically re-export modules.-version: '1.0.0'+version: '1.1.0'
source/library/Autoexporter.hs view
@@ -2,12 +2,16 @@  import qualified Data.List as List import qualified Data.Maybe as Maybe+import qualified Data.Traversable as Traversable import qualified Distribution.ModuleName as ModuleName import qualified Distribution.Text as Text import qualified System.Directory as Directory import qualified System.Environment as Environment import qualified System.FilePath as FilePath +data ExportScope = ExportScopeShallow+                 | ExportScopeDeep+ main :: IO () main = do   args <- Environment.getArgs@@ -16,16 +20,38 @@ mainWithArgs :: [String] -> IO () mainWithArgs args =   case args of-    [name, inputFile, outputFile] -> autoexport name inputFile outputFile+    [name, inputFile, outputFile, "--deep"] ->+      autoexport ExportScopeDeep name inputFile outputFile+    [name, inputFile, outputFile] ->+      autoexport ExportScopeShallow name inputFile outputFile     _ -> fail ("unexpected arguments: " ++ show args) -autoexport :: String -> FilePath -> FilePath -> IO ()-autoexport name inputFile outputFile = do+autoexport :: ExportScope -> String -> FilePath -> FilePath -> IO ()+autoexport exportScope name inputFile outputFile = do   let moduleName = makeModuleName name   let directory = FilePath.dropExtension inputFile-  files <- Directory.getDirectoryContents directory+  files <- findFiles exportScope directory   let output = makeOutput moduleName directory files   writeFile outputFile output++findFiles :: ExportScope -> FilePath -> IO [FilePath]+findFiles exportScope dir =+  case exportScope of+    ExportScopeShallow ->+      fmap (filter isHaskellFile) (Directory.listDirectory dir)+    ExportScopeDeep ->+      findFilesDeep dir++findFilesDeep :: FilePath -> IO [FilePath]+findFilesDeep dir = do+  rootItems <- Directory.listDirectory dir+  childItems <- Traversable.for rootItems $ \item -> do+    let path = dir FilePath.</> item+    dirExists <- Directory.doesDirectoryExist path+    if dirExists+      then fmap (fmap (item FilePath.</>)) (findFilesDeep path)+      else pure []+  pure $ mconcat (filter isHaskellFile rootItems : childItems)  makeModuleName :: FilePath -> String makeModuleName name =
stack.yaml view
@@ -1,1 +1,1 @@-resolver: lts-7.14+resolver: lts-8.0