You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

32 lines
1002 B

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Shared where
import ClassyPrelude.Conduit
import Shelly (Sh, run, fromText)
import Text.ProjectTemplate (createTemplate)
import Filesystem (createTree)
import Filesystem.Path (directory)
branches :: [Text]
branches = ["postgres", "sqlite", "mysql", "mongo", "simple", "postgres-fay"]
master :: Text
master = "postgres"
-- | Works in the current Shelly directory. Confusingly, the @FilePath@
-- destination is relative to the original working directory.
createHsFiles :: FilePath -- ^ root
-> Text -- ^ branch
-> FilePath -- ^ destination
-> Sh ()
createHsFiles root branch fp = do
files <- run "git" ["ls-tree", "-r", branch, "--name-only"]
liftIO $ createTree $ directory fp
liftIO
$ runResourceT
$ mapM_ (yield . toPair . fromText) (lines files)
$$ createTemplate
=$ sinkFile fp
where
toPair fp' = (fp', readFile $ root </> fp')