packages feed

stack-run 0.1.0.6 → 0.1.0.7

raw patch · 3 files changed

+28/−7 lines, 3 filesdep +asyncdep +time

Dependencies added: async, time

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2015 Pedro Tacla Yamada+Copyright (c) 2016 Pedro Tacla Yamada  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
src/Main.hs view
@@ -1,7 +1,8 @@ module Main   where -import           Control.Applicative                   ((<$>))+import           Control.Applicative                   ((*>), (<$>))+import           Control.Concurrent.Async import           Control.Monad                         (unless) import qualified Data.ByteString.Char8                 as ByteString import           Data.Conduit@@ -11,6 +12,7 @@ import           Data.List import           Data.List.Utils import           Data.Maybe+import           Data.Time import           Distribution.PackageDescription import           Distribution.PackageDescription.Parse import           System.Console.ANSI@@ -74,7 +76,12 @@         case ec of             ExitSuccess -> return ()             f -> exitWith f+    start <- getCurrentTime     ec <- prettyRunCommand "stack build"+    hSetSGR stderr [SetColor Foreground Vivid Black]+    fdiff <- getDiffTime start+    hPutStrLn stderr ("stack build took " ++ show fdiff ++ "ms")+    hSetSGR stderr [Reset]     case ec of         ExitSuccess -> do             let cmd = "stack exec " ++ name ++ " -- " ++ join " " as@@ -85,14 +92,25 @@             ec' <- waitForProcess ph             exitWith ec'         f -> exitWith f+  where+    getDiffTime :: UTCTime -> IO Integer+    getDiffTime start = do+        now <- getCurrentTime+        let diff :: Double+            diff = fromRational (toRational (diffUTCTime now start))+            fdiff = floor (diff * 1000)+        return fdiff + prettyRunCommand :: String -> IO ExitCode prettyRunCommand cmd = do+    hSetBuffering stderr LineBuffering     logCommand cmd     (Inherited, out, err, cph) <- streamingProcess (shell cmd)-    out =$= Conduit.Binary.lines $$ Conduit.List.mapM_ putLineGray-    err =$= Conduit.Binary.lines $$ Conduit.List.mapM_ putLineRed-    waitForStreamingProcess cph+    runConcurrently $+        Concurrently (out $$ (Conduit.Binary.lines =$ Conduit.List.mapM_ putLineGray)) *>+        Concurrently (err $$ (Conduit.Binary.lines =$ Conduit.List.mapM_ putLineRed)) *>+        Concurrently (waitForStreamingProcess cph)   where     putLineSGR sgr b = do         hSetSGR stderr sgr
stack-run.cabal view
@@ -1,5 +1,5 @@ name:                stack-run-version:             0.1.0.6+version:             0.1.0.7 synopsis:            An equivalent to cabal run for stack. description:         Finds the project root, compiles your code and runs the                      first or set default executable. It's a shorthand for@@ -10,7 +10,7 @@ license-file:        LICENSE author:              Pedro Tacla Yamada maintainer:          tacla.yamada@gmail.com-copyright:           Copyright (c) 2015 Pedro Tacla Yamada+copyright:           Copyright (c) 2016 Pedro Tacla Yamada category:            Development build-type:          Simple extra-source-files:  README.md@@ -23,6 +23,7 @@   build-depends:       Cabal                      , MissingH                      , ansi-terminal >= 0.6+                     , async                      , base >=4 && <5                      , bytestring >= 0.10                      , conduit > 1.1 && < 1.3@@ -30,8 +31,10 @@                      , directory                      , filepath                      , projectroot >= 0.2+                     , time >= 1.5.0.1   hs-source-dirs:      src   default-language:    Haskell2010+  ghc-options:       -threaded  source-repository head   type:     git