foliage/app/Foliage/Shake.hs

36 lines
960 B
Haskell
Raw Normal View History

module Foliage.Shake
( computeFileInfoSimple',
readFileByteStringLazy,
readKeysAt,
readPackageVersionMeta',
)
where
import Data.ByteString.Lazy qualified as BSL
import Data.Traversable (for)
import Development.Shake
import Development.Shake.FilePath
import Foliage.HackageSecurity
import Foliage.Meta
computeFileInfoSimple' :: FilePath -> Action FileInfo
computeFileInfoSimple' fp = do
2022-05-26 05:55:30 +03:00
need [fp]
liftIO $ computeFileInfoSimple fp
readFileByteStringLazy :: FilePath -> Action BSL.ByteString
readFileByteStringLazy x = need [x] >> liftIO (BSL.readFile x)
readKeysAt :: FilePath -> Action [Some Key]
readKeysAt base = do
2022-03-30 07:32:49 +03:00
paths <- getDirectoryFiles base ["*.json"]
need $ map (base </>) paths
for paths $ \path -> do
Right key <- liftIO $ readJSONSimple (base </> path)
pure key
readPackageVersionMeta' :: FilePath -> Action PackageVersionMeta
readPackageVersionMeta' fp = do
need [fp]
liftIO $ readPackageVersionMeta fp