weeder 0.1 → 0.1.1
raw patch · 3 files changed
+7/−8 lines, 3 files
Files
- CHANGES.txt +2/−0
- src/Stack.hs +4/−7
- weeder.cabal +1/−1
CHANGES.txt view
@@ -1,4 +1,6 @@ Changelog for Weeder +0.1.1+ #2, use "stack query" rather than parsing stack.yaml 0.1 Initial version
src/Stack.hs view
@@ -7,7 +7,7 @@ import Control.Exception import qualified Data.Text as T import qualified Data.HashMap.Strict as Map-import qualified Data.Vector as V+import qualified Data.ByteString.Char8 as BS import System.Process import Data.Functor import Prelude@@ -26,13 +26,10 @@ parseStack :: FilePath -> IO Stack parseStack file = do stackDistDir <- fst . line1 <$> readCreateProcess (proc "stack" ["path","--dist-dir","--stack-yaml=" ++ file]) ""- stackPackages <- either throwIO (return . f) =<< decodeFileEither file+ stackPackages <- f . decodeYaml <$> readCreateProcess (proc "stack" ["query","locals","--stack-yaml=" ++ file]) "" return Stack{..} where+ decodeYaml = either throw id . decodeEither' . BS.pack fromObject (Object x) = x- fromArray (Array xs) = V.toList xs fromString (String s) = T.unpack s-- f x = case Map.lookup "packages" $ fromObject x of- Nothing -> ["."]- Just xs -> map fromString $ fromArray xs+ f = map (fromString . (Map.! "path") . fromObject) . Map.elems . fromObject
weeder.cabal view
@@ -1,7 +1,7 @@ cabal-version: >= 1.18 build-type: Simple name: weeder-version: 0.1+version: 0.1.1 license: BSD3 license-file: LICENSE category: Development