git.iko.soy/typeable/file-embed
on 413bccf help sign in
3 files changed+5−20
since splitsnapshots
unifiedsplit
ChangeLog.md−4 Data/FileEmbed.hs+4−15 file-embed.cabal+1−1
ChangeLog.md−4
@@ -1,9 +1,5 @@
11# ChangeLog for file-embed
22
3−## 0.0.15.0
4−
5−* Add `makeRelativeToLocationPredicate`
6−
73## 0.0.14.0
84
95* Add `embedFileIfExists`
Data/FileEmbed.hs+4−15
@@ -39,7 +39,6 @@ module Data.FileEmbed
3939 , injectFileWith
4040 -- * Relative path manipulation
4141 , makeRelativeToProject
42− , makeRelativeToLocationPredicate
4342 -- * Internal
4443 , stringToBs
4544 , bsToExp
@@ -409,19 +408,7 @@ available, you can use the non-@With@ variants.
409408--
410409-- @since 0.0.10
411410makeRelativeToProject :: 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
411+makeRelativeToProject rel = do
425412 loc <- qLocation
426413 runIO $ do
427414 srcFP <- canonicalizePath $ loc_filename loc
@@ -436,6 +423,8 @@ makeRelativeToLocationPredicate isTargetFile rel = do
436423 then return Nothing
437424 else do
438425 contents <- getDirectoryContents dir
439− if any isTargetFile contents
426+ if any isCabalFile contents
440427 then return (Just dir)
441428 else findProjectDir dir
429+
430+ isCabalFile fp = takeExtension fp == ".cabal"
file-embed.cabal+1−1
@@ -1,5 +1,5 @@
11name: file-embed
2−version: 0.0.15.0
2+version: 0.0.14.0
33license: BSD2
44license-file: LICENSE
55author: Michael Snoyman <michael@snoyman.com>