packages feed

zifter-stack 0.0.0.4 → 0.0.0.5

raw patch · 2 files changed

+27/−40 lines, 2 files

Files

src/Zifter/Stack.hs view
@@ -2,21 +2,12 @@  import Control.Monad import Control.Monad.IO.Class-import Data.List (isInfixOf)+import Data.List (isPrefixOf) import Path-import Path.IO-import Safe import System.Exit (ExitCode(..))-import qualified System.FilePath as FP (splitPath) import System.IO import System.Process -import Distribution.Package-import Distribution.PackageDescription-import Distribution.PackageDescription.Configuration-import Distribution.PackageDescription.Parse-import Distribution.Verbosity- import Zifter.Zift  stackBuildZift :: Zift ()@@ -26,9 +17,12 @@  stackCheckAndPrintVersion :: Zift () stackCheckAndPrintVersion = do+    rd <- getRootDir     let cmd = "stack --version"     (_, mouth, _, ph) <--        liftIO $ createProcess ((shell cmd) {std_out = CreatePipe})+        liftIO $+        createProcess+            ((shell cmd) {cwd = Just $ toFilePath rd, std_out = CreatePipe})     ec <- liftIO $ waitForProcess ph     case mouth of         Nothing -> pure ()@@ -40,25 +34,26 @@ stackGetPackageTargetTuples :: Zift [(String, [String])] stackGetPackageTargetTuples = do     rd <- getRootDir-    (_, fs) <- liftIO $ listDirRecur rd-    let cabalFiles =-            filter (not . isInfixOf ".stack-work" . toFilePath) $-            filter (not . hidden) $ filter ((== ".cabal") . fileExtension) fs-    (concat <$>) $-        forM cabalFiles $ \cabalFile -> do-            pd <--                liftIO $ readPackageDescription deafening $ toFilePath cabalFile-            let packageDesc = flattenPackageDescription pd-                name = unPackageName $ pkgName $ package packageDesc-                libname = name ++ ":lib"-                lib =-                    case library packageDesc of-                        Nothing -> []-                        Just _ -> [libname]-                testnames =-                    map (((name ++ ":test:") ++) . testName) $-                    testSuites packageDesc-            pure [(name, lib ++ testnames)]+    let getErrFrom cmd = do+            (_, _, merrh, ph) <-+                liftIO $+                createProcess+                    ((shell cmd)+                     {cwd = Just $ toFilePath rd, std_err = CreatePipe})+            ec <- liftIO $ waitForProcess ph+            case ec of+                ExitFailure c ->+                    fail $ unwords [show cmd, "failed with exit code", show c]+                ExitSuccess -> pure ()+            case merrh of+                Nothing ->+                    fail $ unwords ["Failed to capture output of", show cmd]+                Just outh -> liftIO (hGetContents outh)+    outt <- getErrFrom "stack ide targets"+    outp <- getErrFrom "stack ide packages"+    let targets = lines outt+    let packages = lines outp+    pure $ flip map packages $ \t -> (t, filter (isPrefixOf t) targets)  stackBuild :: Zift () stackBuild = do@@ -91,12 +86,4 @@     forM_ tups $ \(package_, targets) -> do         stack $ unwords ["clean", package_]         forM_ targets $ \target ->-            stack $-            unwords-                [ "build --pedantic --haddock --test"-                , target-                , "--test-arguments='--fail-fast --seed=42'"-                ]--hidden :: Path Abs t -> Bool-hidden = any ((Just '.' ==) . headMay) . FP.splitPath . toFilePath+            stack $ unwords ["build --pedantic --haddock --test", target]
zifter-stack.cabal view
@@ -1,5 +1,5 @@ name: zifter-stack-version: 0.0.0.4+version: 0.0.0.5 cabal-version: >=1.10 build-type: Simple license: MIT