From 8f31bec0bb99b3b0aef53d25249a3b54a7b3b74e Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 24 Jan 2024 19:15:05 +0000 Subject: [PATCH 1/4] Add embedFileRelative function. --- Data/FileEmbed.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs index 3b86175..d3d66fa 100644 --- a/Data/FileEmbed.hs +++ b/Data/FileEmbed.hs @@ -19,6 +19,7 @@ module Data.FileEmbed ( -- * Embed at compile time embedFile + , embedFileRelative , embedFileIfExists , embedOneFileOf , embedDir @@ -63,7 +64,7 @@ import qualified Data.ByteString.Internal as B import System.Directory (doesDirectoryExist, doesFileExist, getDirectoryContents, canonicalizePath) import Control.Exception (throw, tryJust, ErrorCall(..)) -import Control.Monad (filterM, guard) +import Control.Monad ((<=<), filterM, guard) import qualified Data.ByteString as B import qualified Data.ByteString.Char8 as B8 import Control.Arrow ((&&&), second) @@ -90,6 +91,11 @@ embedFile fp = #endif (runIO $ B.readFile fp) >>= bsToExp +-- | Embed a file file in your source code. +-- Unlike 'embedFile', path is given relative to project root. +embedFileRelative :: FilePath -> Q Exp +embedFileRelative = embedFile <=< makeRelativeToProject + -- | Maybe embed a single file in your source code depending on whether or not file exists. -- -- Warning: When a build is compiled with the file missing, a recompile when the file exists might not trigger an embed of the file. From c8d4a5c950df72afd08251e39f5474ecffc35576 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 25 Jan 2024 10:31:53 +0000 Subject: [PATCH 2/4] Bump version, add changelog entry. --- ChangeLog.md | 4 ++++ Data/FileEmbed.hs | 1 + file-embed.cabal | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 582f1b5..9749c26 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,9 @@ # ChangeLog for file-embed +## 0.0.15.1 + +* Add `embedFileRelative` + ## 0.0.15.0 * Add `makeRelativeToLocationPredicate` diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs index d3d66fa..befcb31 100644 --- a/Data/FileEmbed.hs +++ b/Data/FileEmbed.hs @@ -93,6 +93,7 @@ embedFile fp = -- | Embed a file file in your source code. -- Unlike 'embedFile', path is given relative to project root. +-- @since 0.0.15.1 embedFileRelative :: FilePath -> Q Exp embedFileRelative = embedFile <=< makeRelativeToProject diff --git a/file-embed.cabal b/file-embed.cabal index 9246e58..4578073 100644 --- a/file-embed.cabal +++ b/file-embed.cabal @@ -1,5 +1,5 @@ name: file-embed -version: 0.0.15.0 +version: 0.0.15.1 license: BSD2 license-file: LICENSE author: Michael Snoyman From 3a6361de8fdb7ec10403d338398621c21822e630 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 25 Jan 2024 10:37:04 +0000 Subject: [PATCH 3/4] Fix comment typo. --- Data/FileEmbed.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs index befcb31..79d0d64 100644 --- a/Data/FileEmbed.hs +++ b/Data/FileEmbed.hs @@ -91,7 +91,7 @@ embedFile fp = #endif (runIO $ B.readFile fp) >>= bsToExp --- | Embed a file file in your source code. +-- | Embed a single file in your source code. -- Unlike 'embedFile', path is given relative to project root. -- @since 0.0.15.1 embedFileRelative :: FilePath -> Q Exp From 001cdedeacad9f38c24f2439c6b9c43c46363cc9 Mon Sep 17 00:00:00 2001 From: Nick Date: Fri, 26 Jan 2024 09:42:08 +0000 Subject: [PATCH 4/4] Bump version to 0.0.16.0 --- ChangeLog.md | 2 +- Data/FileEmbed.hs | 2 +- file-embed.cabal | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 9749c26..263d85a 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,6 @@ # ChangeLog for file-embed -## 0.0.15.1 +## 0.0.16.0 * Add `embedFileRelative` diff --git a/Data/FileEmbed.hs b/Data/FileEmbed.hs index 79d0d64..2b55464 100644 --- a/Data/FileEmbed.hs +++ b/Data/FileEmbed.hs @@ -93,7 +93,7 @@ embedFile fp = -- | Embed a single file in your source code. -- Unlike 'embedFile', path is given relative to project root. --- @since 0.0.15.1 +-- @since 0.0.16.0 embedFileRelative :: FilePath -> Q Exp embedFileRelative = embedFile <=< makeRelativeToProject diff --git a/file-embed.cabal b/file-embed.cabal index 4578073..a13dc4c 100644 --- a/file-embed.cabal +++ b/file-embed.cabal @@ -1,5 +1,5 @@ name: file-embed -version: 0.0.15.1 +version: 0.0.16.0 license: BSD2 license-file: LICENSE author: Michael Snoyman