hi 1.1.0.2 → 1.1.0.3
raw patch · 2 files changed
+20/−5 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
hi.cabal view
@@ -1,5 +1,5 @@ name: hi-version: 1.1.0.2+version: 1.1.0.3 cabal-version: >=1.8 build-type: Simple license: BSD3
src/Hi.hs view
@@ -17,7 +17,7 @@ import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Lazy as LBS (toChunks) import Data.List ((\\))-import Data.Maybe (fromJust)+import Data.Maybe (fromMaybe) import qualified Data.Text as T (pack, unpack) import Data.Text.Encoding (decodeUtf8) import Data.Text.Lazy.Encoding (encodeUtf8)@@ -63,7 +63,7 @@ -- 2. Substitute arguments -- 3. Drop regular files if template file with same name exists process :: Option -> Files -> Files-process Option {..} = dropExtraRegularFiles . map go+process Option {..} = dropExtraRegularFiles . map go . dropFilesInRoot where go (TemplateFile path content) = TemplateFile (rewritePath' path) (substitute' content) go (RegularFile path content) = RegularFile (rewritePath' path) content@@ -77,9 +77,10 @@ ,("year", year) ] --- | Return 'Context' obtained by given 'Options'+-- | Return 'Context' obtained by given 'Options'. An identifier which has no+-- corresponding context will not be substituted. context :: [(String, String)] -> Context-context opts x = T.pack . fromJust $ lookup (T.unpack x) opts+context opts x = let x' = T.unpack x in T.pack . (fromMaybe ("$" ++ x')) $ lookup x' opts postProcess :: Option -> IO () postProcess Option {packageName, afterCommands} = do@@ -102,3 +103,17 @@ then go paths ys else y : go paths ys go paths (y@(TemplateFile _ _):ys) = y : go paths ys++-- | Drop all files in root directory.+--+-- >>> dropFilesInRoot [RegularFile "package-name/README.md" (BS.pack "a"), RegularFile "foo" (BS.pack "b")]+-- [RegularFile {getFilePath = "package-name/README.md", getFileContents = "a"}]+--+dropFilesInRoot :: Files -> Files+dropFilesInRoot [] = []+dropFilesInRoot (x:xs) = go (splitPath $ getFilePath x)+ where+ go [] = dropFilesInRoot xs+ go (path:_) = if "package-name/" == path+ then x : dropFilesInRoot xs+ else dropFilesInRoot xs