buildbox 2.1.2.3 → 2.1.2.4
raw patch · 4 files changed
+25/−20 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- BuildBox.hs +1/−4
- BuildBox/Build.hs +1/−1
- BuildBox/Command/File.hs +22/−14
- buildbox.cabal +1/−1
BuildBox.hs view
@@ -20,7 +20,4 @@ , outLn) where import BuildBox.Build---- Need to hide catch to build with GHC 7.4, --- but it's not exported with GHC 7.6.-import Prelude hiding (catch)+import Prelude
BuildBox/Build.hs view
@@ -37,7 +37,7 @@ import BuildBox.Build.BuildError import Control.Monad.State import System.IO-import Prelude hiding (catch)+import Prelude -- | Log a system command to the handle in our `BuildConfig`, if any.
BuildBox/Command/File.hs view
@@ -10,8 +10,8 @@ , atomicWriteFile) where import BuildBox.Build-import BuildBox.Command.System import System.Directory+import Control.Exception import Control.Monad.State -- | Properties of the file system we can test for.@@ -35,8 +35,10 @@ test prop = case prop of HasExecutable name- -> do (code, _, _) <- systemq $ "which " ++ name- return $ code == ExitSuccess+ -> do bin <- io $ findExecutable name+ return $ case bin of+ Just _ -> True+ Nothing -> False HasFile path -> io $ doesFileExist path@@ -70,29 +72,30 @@ -- Make sure a dir with this name doesn't already exist. checkFalse $ HasDir name - ssystem $ "mkdir -p " ++ name -- TODO: rewrite without shell options+ ensureDir name x <- inDir name build+ clobberDir name - ssystem $ "rm -Rf " ++ name -- TODO: rewrite without shell opts return x -- | Delete a dir recursively if it's there, otherwise do nothing.--- Unlike `removeDirectoryRecursive`, this function does--- not follow symlinks, it just deletes them. clobberDir :: FilePath -> Build () clobberDir path- = do ssystemq $ "rm -Rf " ++ path -- TODO: rewrite without shell opts- return ()+ = do e <- io $ try $ removeDirectoryRecursive path+ case (e :: Either SomeException ()) of+ _ -> return () + -- | Create a new directory if it isn't already there, or return successfully if it is. ensureDir :: FilePath -> Build () ensureDir path = do already <- io $ doesDirectoryExist path if already then return ()- else do ssystemq $ "mkdir -p " ++ path -- TODO: rewrite without shell opts- return ()+ else do e <- io $ try $ createDirectoryIfMissing True path+ case (e :: Either SomeException ()) of+ _ -> return () -- | Create a temp file, pass it to some command, then delete the file after the command finishes.@@ -123,7 +126,10 @@ ensureDir buildDir -- Build the file name we'll try to use.- let fileName = buildDir ++ "/buildbox-" ++ show buildId ++ "-" ++ show buildSeq + -- We need to account for a blank scratch directory, otherwise there is+ -- no way to use the CD as a scratch on Windows.+ let fileName = (if (null buildDir) then "" else (buildDir ++ "/"))+ ++ "buildbox-" ++ show buildId ++ "-" ++ show buildSeq -- TODO: normalise path -- If it already exists then something has gone badly wrong.@@ -145,5 +151,7 @@ atomicWriteFile filePath str = do tmp <- newTempFile io $ writeFile tmp str- ssystemq $ "mv " ++ tmp ++ " " ++ filePath- return ()+ e <- io $ try $ renameFile tmp filePath+ case (e :: Either SomeException ()) of+ _ -> return ()+
buildbox.cabal view
@@ -1,5 +1,5 @@ Name: buildbox-Version: 2.1.2.3+Version: 2.1.2.4 License: BSD3 License-file: LICENSE Author: Ben Lippmeier