Add IsDirectory
This commit is contained in:
parent
da7ea65cf5
commit
8aaa056978
|
@ -28,6 +28,7 @@ module DependencyGenerator
|
|||
, applyTemplate
|
||||
, toText
|
||||
, listDirectory
|
||||
, isDirectory
|
||||
, readTemplate
|
||||
, convertImage
|
||||
, saveFile
|
||||
|
@ -214,6 +215,9 @@ toText a = runFunction ToText =<< toToken a
|
|||
listDirectory :: TokenableTo FilePath a => a -> DepGenM' [FilePath]
|
||||
listDirectory a = runFunctionIO ListDirectory =<< toToken a
|
||||
|
||||
isDirectory :: TokenableTo FilePath a => a -> DepGenM' Bool
|
||||
isDirectory a = runFunctionIO IsDirectory =<< toToken a
|
||||
|
||||
readTemplate :: TokenableTo FilePath a => a -> DepGenM' Template
|
||||
readTemplate a = runFunctionIO ReadTemplate =<< toToken a
|
||||
|
||||
|
|
|
@ -12,13 +12,16 @@ import qualified Text.Pandoc as P
|
|||
import qualified Text.Blaze.Html.Renderer.Text as B
|
||||
import qualified Codec.Picture as CP
|
||||
import qualified Codec.Picture.STBIR as CPS
|
||||
import System.Directory (listDirectory, createDirectory, copyFile)
|
||||
import System.Directory (listDirectory, doesDirectoryExist, createDirectory, copyFile)
|
||||
|
||||
evalFunctionIO :: FunctionIO -> Value -> IO Value
|
||||
evalFunctionIO f x = case (f, x) of
|
||||
(ListDirectory, String s) ->
|
||||
(List . map toValue) <$> listDirectory s
|
||||
|
||||
(IsDirectory, String s) ->
|
||||
Bool <$> doesDirectoryExist s
|
||||
|
||||
(ReadTemplate, String s) -> do
|
||||
t <- T.readFile s
|
||||
let c = "CONTENT"
|
||||
|
|
|
@ -5,6 +5,7 @@ module Types.FunctionIO
|
|||
import Language.Haskell.TH.Syntax (Lift)
|
||||
|
||||
data FunctionIO = ListDirectory
|
||||
| IsDirectory
|
||||
| ReadTemplate
|
||||
| ConvertImage
|
||||
| SaveFile
|
||||
|
|
Loading…
Reference in New Issue