packages feed

rio 0.1.20.0 → 0.1.21.0

raw patch · 6 files changed

+57/−15 lines, 6 filesdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: base

API changes (from Hackage documentation)

+ RIO.Process: instance GHC.Classes.Eq RIO.Process.ProcessException

Files

ChangeLog.md view
@@ -1,5 +1,9 @@ # Changelog for rio +## 0.1.21.0++* Fix minor bug in `augmentPathMap` on windows wrt [#234](https://github.com/commercialhaskell/rio/issues/234) not adhering to case-insensitive semantics+ ## 0.1.20.0  * Export `UnliftIO.QSem` and `UnliftIO.QSemN` in `RIO`
README.md view
@@ -4,7 +4,7 @@  ![Rio](https://camo.githubusercontent.com/fc162fb0024699c85f00eae769085a5fe528153e/68747470733a2f2f7777772e61687374617469632e636f6d2f70686f746f732f636974792f76692d76363837315f30305f31343030783434322e6a7067) -[![Build Status](https://dev.azure.com/snoyberg/rio/_apis/build/status/commercialhaskell.rio?branchName=master)](https://dev.azure.com/snoyberg/rio/_build/latest?definitionId=6&branchName=master)+![Tests](https://github.com/commercialhaskell/rio/workflows/Tests/badge.svg)  The goal of the `rio` library is to make it easier to adopt Haskell for writing production software.  It is intended as a cross between:
rio.cabal view
@@ -1,13 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.33.0.+-- This file has been generated from package.yaml by hpack version 0.34.4. -- -- see: https://github.com/sol/hpack------ hash: f3c92fe72c8e7fd35fdebcde2b50c754eec24d9c4d5bc1bded6f7876503fb693  name:           rio-version:        0.1.20.0+version:        0.1.21.0 synopsis:       A standard library for Haskell description:    See README and Haddocks at <https://www.stackage.org/package/rio> category:       Control@@ -94,7 +92,7 @@   hs-source-dirs:       src/   build-depends:-      base >=4.10 && <10+      base >=4.12 && <10     , bytestring     , containers     , deepseq@@ -142,7 +140,7 @@       test   build-depends:       QuickCheck-    , base >=4.10 && <10+    , base >=4.12 && <10     , bytestring     , containers     , deepseq@@ -172,3 +170,5 @@     build-depends:         unix   default-language: Haskell2010+  build-tool-depends:+      hspec-discover:hspec-discover
src/RIO/Prelude/Logger.hs view
@@ -335,6 +335,8 @@ -- | Create a 'LogOptions' value from the given 'Handle' and whether -- to perform verbose logging or not. Individiual settings can be -- overridden using appropriate @set@ functions.+-- Logging output is guaranteed to be non-interleaved only for a+-- UTF-8 'Handle' in a multi-thread environment. -- -- When Verbose Flag is @True@, the following happens: --
src/RIO/Process.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ViewPatterns #-}  -- | Interacting with external processes. --@@ -190,7 +191,7 @@     | ExecutableNotFound String [FilePath]     | ExecutableNotFoundAt FilePath     | PathsInvalidInPath [FilePath]-    deriving Typeable+    deriving (Typeable, Eq) instance Show ProcessException where     show NoPathFound = "PATH not found in ProcessContext"     show (ExecutableNotFound name path) = concat@@ -269,7 +270,7 @@ -- -- @since 0.0.3.0 mkProcessContext :: MonadIO m => EnvVars -> m ProcessContext-mkProcessContext tm' = do+mkProcessContext (normalizePathEnv -> tm) = do     ref <- newIORef Map.empty     return ProcessContext         { pcTextMap = tm@@ -287,10 +288,6 @@         , pcWorkingDir = Nothing         }   where-    -- Fix case insensitivity of the PATH environment variable on Windows.-    tm-        | isWindows = Map.fromList $ map (first T.toUpper) $ Map.toList tm'-        | otherwise = tm'     -- Default value for PATHTEXT on Windows versions after Windows XP. (The     -- documentation of the default at     -- https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/start@@ -298,6 +295,14 @@     defaultPATHEXT = ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"  +-- Fix case insensitivity of the PATH environment variable on Windows,+-- by forcing all keys full uppercase.+normalizePathEnv :: EnvVars -> EnvVars+normalizePathEnv env+  | isWindows = Map.fromList $ map (first T.toUpper) $ Map.toList env+  | otherwise = env++ -- | Reset the executable cache. -- -- @since 0.0.3.0@@ -654,7 +659,8 @@   pc <- view processContextL   return $ pcExeExtensions pc --- | Augment the PATH environment variable with the given extra paths.+-- | Augment the PATH environment variable with the given extra paths,+-- which are prepended (as in: they take precedence). -- -- @since 0.0.3.0 augmentPath :: [FilePath] -> Maybe Text -> Either ProcessException Text@@ -670,7 +676,7 @@ -- -- @since 0.0.3.0 augmentPathMap :: [FilePath] -> EnvVars -> Either ProcessException EnvVars-augmentPathMap dirs origEnv =+augmentPathMap dirs (normalizePathEnv -> origEnv) =   do path <- augmentPath dirs mpath      return $ Map.insert "PATH" path origEnv   where
test/RIO/Prelude/ExtraSpec.hs view
@@ -1,8 +1,16 @@+{-# LANGUAGE CPP #-}+{-# LANGUAGE OverloadedStrings #-}+ module RIO.Prelude.ExtraSpec (spec) where  import RIO+import RIO.Process import Test.Hspec +import qualified Data.Map as Map+import qualified Data.Text as T+import qualified System.FilePath as FP+ spec :: Spec spec = do   describe "foldMapM" $ do@@ -11,3 +19,25 @@           helper = pure . pure       res <- foldMapM helper [1..10]       res `shouldBe` [1..10]+  describe "augmentPathMap" $ do+    -- https://github.com/commercialhaskell/rio/issues/234+    it "Doesn't duplicate PATH keys on windows" $ do+      let pathKey :: T.Text+#if WINDOWS+          pathKey = "Path"+#else+          pathKey = "PATH"+#endif+          origEnv :: EnvVars+          origEnv = Map.fromList [ ("foo", "3")+                                 , ("bar", "baz")+                                 , (pathKey, makePath ["/local/bin", "/usr/bin"])+                                 ]+      let res = second (fmap getPaths . Map.lookup "PATH") $ augmentPathMap ["/bin"] origEnv+      res `shouldBe` Right (Just ["/bin", "/local/bin", "/usr/bin"])+  where+    makePath :: [T.Text] -> T.Text+    makePath = T.intercalate (T.singleton FP.searchPathSeparator)++    getPaths :: T.Text -> [T.Text]+    getPaths = fmap T.pack . FP.splitSearchPath . T.unpack