Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
## MASTER
## Dotenv 0.10.0.0
### Modified
* `loadFile` change return type (back to `m ()`)

## Dotenv 0.9.0.3
### Added
* Parse multi-word command interpolations (Kudos to @pbrisbin)
Expand Down
3 changes: 1 addition & 2 deletions app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Options.Applicative
import Paths_dotenv (version)

import Configuration.Dotenv (Config (..), defaultConfig, loadFile)
import Control.Monad (void)
import System.Exit (exitWith)
import System.Process (system)

Expand Down Expand Up @@ -41,7 +40,7 @@ main = do
else dotenvFiles
}
in do
void $ loadFile configDotenv
loadFile configDotenv
system (program ++ concatMap (" " ++) args) >>= exitWith
where
opts = info (helper <*> versionOption <*> config)
Expand Down
2 changes: 1 addition & 1 deletion dotenv.cabal
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: dotenv
version: 0.9.0.3
version: 0.10.0.0
synopsis: Loads environment variables from dotenv files
homepage: https://github.com/stackbuilders/dotenv-hs
description:
Expand Down
16 changes: 8 additions & 8 deletions spec/Configuration/DotenvSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Configuration.Dotenv.Types (Config (..))

import Test.Hspec

import Control.Monad (liftM, void)
import Control.Monad (liftM)
import Data.Maybe (fromMaybe)
import System.Process (readCreateProcess, shell)

Expand Down Expand Up @@ -47,21 +47,21 @@ spec = do
it "loads the configuration options to the environment from a file" $ do
lookupEnv "DOTENV" `shouldReturn` Nothing

void $ loadFile sampleConfig
loadFile sampleConfig

lookupEnv "DOTENV" `shouldReturn` Just "true"

it "respects predefined settings when overload is false" $ do
setEnv "DOTENV" "preset"

void $ loadFile sampleConfig
loadFile sampleConfig

lookupEnv "DOTENV" `shouldReturn` Just "preset"

it "overrides predefined settings when overload is true" $ do
setEnv "DOTENV" "preset"

void $ loadFile sampleConfig { configOverride = True }
loadFile sampleConfig { configOverride = True }

lookupEnv "DOTENV" `shouldReturn` Just "true"

Expand All @@ -70,7 +70,7 @@ spec = do
context "when the needed env vars are missing" $
it "should fail with an error call" $ do
unsetEnv "ANOTHER_ENV"
void $ loadFile config `shouldThrow` anyErrorCall
loadFile config `shouldThrow` anyErrorCall

context "when the needed env vars are not missing" $
it "should succeed when loading all of the needed env vars" $ do
Expand All @@ -79,7 +79,7 @@ spec = do
home <- fromMaybe "" <$> lookupEnv "HOME"

-- Load envs
void $ loadFile config
loadFile config

-- Check existing envs
lookupEnv "ENVIRONMENT" `shouldReturn` Just home
Expand Down Expand Up @@ -124,7 +124,7 @@ spec = do
describe "onMissingFile" $ after_ clearEnvs $ do
context "when target file is present" $
it "loading works as usual" $ do
void $ onMissingFile (loadFile sampleConfig {configOverride = True}) (return [])
onMissingFile (loadFile sampleConfig {configOverride = True}) (return ())
lookupEnv "DOTENV" `shouldReturn` Just "true"

context "when target file is missing" $
Expand All @@ -138,7 +138,7 @@ spec = do
loadFile sampleConfig { configPath = ["spec/fixtures/.dotenv", "spec/fixtures/.dotenv"], allowDuplicates = False }
`shouldThrow` anyIOException
it "works as usual when there is no duplicated keys" $ do
void $ loadFile sampleConfig { allowDuplicates = False }
loadFile sampleConfig { allowDuplicates = False }
lookupEnv "DOTENV" `shouldReturn` Just "true"

sampleConfig :: Config
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/Dotenv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ load override kv =
loadFile ::
MonadIO m
=> Config -- ^ Dotenv configuration
-> m [(String, String)] -- ^ Environment variables loaded
-> m ()
loadFile config@Config {..} = do
environment <- liftIO getEnvironment
readVars <- fmap concat (mapM parseFile configPath)
Expand All @@ -75,7 +75,7 @@ loadFile config@Config {..} = do
concatMap ((++) " " . fst) neededVars
else readVars
unless allowDuplicates $ (lookUpDuplicates . map fst) vars
runReaderT (mapM applySetting vars) config
runReaderT (mapM_ applySetting vars) config

-- | Parses the given dotenv file and returns values /without/ adding them to
-- the environment.
Expand Down