From 837148027e302d2bb102e6200a4ef7dc4ea6b4cc Mon Sep 17 00:00:00 2001 From: Aaron VonderHaar Date: Sat, 11 Mar 2023 13:49:04 -0800 Subject: [PATCH] Build haddock docs on CI (attempt 2) --- Shakefile/build-elm-format.cabal | 1 + Shakefile/package.yaml | 1 + Shakefile/src/Shakefiles/Haskell.hs | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Shakefile/build-elm-format.cabal b/Shakefile/build-elm-format.cabal index a81aa3bbd..096f62741 100644 --- a/Shakefile/build-elm-format.cabal +++ b/Shakefile/build-elm-format.cabal @@ -30,6 +30,7 @@ executable build-elm-format aeson >=2.0.0.0 , base >=4.16.2.0 , directory >=1.3.6.2 + , relude , shake >=0.19.6 && <0.20 , yaml default-language: Haskell2010 diff --git a/Shakefile/package.yaml b/Shakefile/package.yaml index 4cb386498..13598e4c5 100644 --- a/Shakefile/package.yaml +++ b/Shakefile/package.yaml @@ -17,6 +17,7 @@ dependencies: base: ">= 4.16.2.0" directory: ">= 1.3.6.2" shake: ">=0.19.6 && <0.20" + relude: {} yaml: {} diff --git a/Shakefile/src/Shakefiles/Haskell.hs b/Shakefile/src/Shakefiles/Haskell.hs index 5a82e02a4..dc98f7c69 100644 --- a/Shakefile/src/Shakefiles/Haskell.hs +++ b/Shakefile/src/Shakefiles/Haskell.hs @@ -10,11 +10,12 @@ import qualified Shakefiles.Platform import Data.Char (isSpace) import Data.List (dropWhileEnd, stripPrefix) import Shakefiles.Extra -import System.Directory (createDirectoryIfMissing) +import System.Directory (createDirectoryIfMissing, removeDirectoryRecursive) import Data.Yaml (FromJSON, (.:)) import Data.Yaml.TH (FromJSON(..)) import qualified Data.Yaml as Yaml import qualified Data.Aeson.Key as Key +import Relude.Bool.Guard (whenM) docsDir :: FilePath @@ -87,7 +88,11 @@ cabalProject name sourceFiles sourcePatterns deps testPatterns testDeps = buildDir <- cabalBuildDir name let docsBuildDir = buildDir "doc" "html" name liftIO $ createDirectoryIfMissing True docsDir - cmd_ "rsync" "-a" "--delete" (docsBuildDir <> "/") (docsDir name <> "/") + let docsOutDir = docsDir name + whenM + (doesDirectoryExist docsOutDir) + (liftIO $ removeDirectoryRecursive docsOutDir) + cmd_ "cp" "-r" (docsBuildDir <> "/") docsOutDir copyFileChanged haddockOk out