git.iko.soy/typeable/file-embed
on 6633884 help sign in
3 files changed+6−27
since splitsnapshots
unifiedsplit
ChangeLog.md−8 Data/FileEmbed.hs+4−17 file-embed.cabal+2−2
ChangeLog.md−8
@@ -1,13 +1,5 @@
11# ChangeLog for file-embed
22
3−## 0.0.15.0
4−
5−* Add `makeRelativeToLocationPredicate`
6−
7−## 0.0.14.0
8−
9−* Add `embedFileIfExists`
10−
113## 0.0.13.0
124
135* Ensure that directory listings are returned in sorted order for reproducibility [yesodweb/yesod#1684](https://github.com/yesodweb/yesod/issues/1684)
Data/FileEmbed.hs+4−17
@@ -39,7 +39,6 @@ module Data.FileEmbed
3939 , injectFileWith
4040 -- * Relative path manipulation
4141 , makeRelativeToProject
42− , makeRelativeToLocationPredicate
4342 -- * Internal
4443 , stringToBs
4544 , bsToExp
@@ -99,8 +98,6 @@ embedFile fp =
9998-- >
10099-- > maybeMyFile :: Maybe Data.ByteString.ByteString
101100-- > maybeMyFile = $(embedFileIfExists "dirName/fileName")
102−--
103−-- @since 0.0.14.0
104101embedFileIfExists :: FilePath -> Q Exp
105102embedFileIfExists fp = do
106103 mbs <- runIO maybeFile
@@ -409,19 +406,7 @@ available, you can use the non-@With@ variants.
409406--
410407-- @since 0.0.10
411408makeRelativeToProject :: FilePath -> Q FilePath
412−makeRelativeToProject = makeRelativeToLocationPredicate $ (==) ".cabal" . takeExtension
413−
414−-- | Take a predicate to infer the project root and a relative file path, the given file path is then attached to the inferred project root
415−--
416−-- This function looks at the source location of the Haskell file calling it,
417−-- finds the first parent directory with a file matching the given predicate, and uses that as the
418−-- root directory for fixing the relative path.
419−--
420−-- @$(makeRelativeToLocationPredicate ((==) ".cabal" . takeExtension) "data/foo.txt" >>= embedFile)@
421−--
422−-- @since 0.0.15.0
423−makeRelativeToLocationPredicate :: (FilePath -> Bool) -> FilePath -> Q FilePath
424−makeRelativeToLocationPredicate isTargetFile rel = do
409+makeRelativeToProject rel = do
425410 loc <- qLocation
426411 runIO $ do
427412 srcFP <- canonicalizePath $ loc_filename loc
@@ -436,6 +421,8 @@ makeRelativeToLocationPredicate isTargetFile rel = do
436421 then return Nothing
437422 else do
438423 contents <- getDirectoryContents dir
439− if any isTargetFile contents
424+ if any isCabalFile contents
440425 then return (Just dir)
441426 else findProjectDir dir
427+
428+ isCabalFile fp = takeExtension fp == ".cabal"
file-embed.cabal+2−2
@@ -1,6 +1,6 @@
11name: file-embed
2−version: 0.0.15.0
3−license: BSD2
2+version: 0.0.13.0
3+license: BSD3
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>
66maintainer: Michael Snoyman <michael@snoyman.com>