Skip to content

Commit

Permalink
Do not overwrite syntax.css
Browse files Browse the repository at this point in the history
  • Loading branch information
facundominguez committed Feb 4, 2024
1 parent 542441e commit 89c247b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module Language.Haskell.Liquid.UX.Annotate
, annErrors
) where

import Control.Monad (unless)

Check warning on line 23 in liquidhaskell-boot/src/Language/Haskell/Liquid/UX/Annotate.hs

View workflow job for this annotation

GitHub Actions / hlint

Warning in module Language.Haskell.Liquid.UX.Annotate: Use fewer imports ▫︎ Found: "import Control.Monad ( unless )\nimport Control.Monad ( when, forM_ )\n" ▫︎ Perhaps: "import Control.Monad ( unless, when, forM_ )\n"
import Data.Hashable
import qualified Data.Text.IO as Text
import Data.String
Expand Down Expand Up @@ -132,10 +133,16 @@ copyFileCreateParentDirIfMissing src tgt = do
Dir.createDirectoryIfMissing False $ tempDirectory tgt
Dir.copyFile src tgt

-- | Creates the parent directory and writes the file if the
-- file does not exist already.
-- This prevents failure if multiple threads are trying to write to
-- the same file.
writeFileCreateParentDirIfMissing :: T.Text -> FilePath -> IO ()
writeFileCreateParentDirIfMissing s tgt = do
Dir.createDirectoryIfMissing False $ tempDirectory tgt
Text.writeFile tgt s
exists <- Dir.doesFileExist tgt
unless exists $
Text.writeFile tgt s

writeFilesOrStrings :: FilePath -> [Either FilePath String] -> IO ()
writeFilesOrStrings tgtFile = mapM_ $ either (`copyFileCreateParentDirIfMissing` tgtFile) (tgtFile `appendFile`)
Expand Down

0 comments on commit 89c247b

Please sign in to comment.