load-env 0.2.0.0 → 0.2.0.1
raw patch · 5 files changed
+78/−12 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- CHANGELOG.md +1/−0
- README.md +51/−0
- load-env.cabal +5/−2
- src/LoadEnv.hs +10/−10
- test/LoadEnvSpec.hs +11/−0
+ CHANGELOG.md view
@@ -0,0 +1,1 @@+TODO
+ README.md view
@@ -0,0 +1,51 @@+# load-env++[](https://circleci.com/gh/pbrisbin/load-env)++This is effectively a port of [dotenv][], whose README explains it best:++> Storing configuration in the environment is one of the tenets of a+> twelve-factor app. Anything that is likely to change between deployment+> environments–such as resource handles for databases or credentials for+> external services–should be extracted from the code into environment+> variables.+>+> But it is not always practical to set environment variables on development+> machines or continuous integration servers where multiple projects are run.+> dotenv loads variables from a .env file into ENV when the environment is+> bootstrapped.++[dotenv]: https://github.com/bkeepers/dotenv++This library exposes functions for doing just that.++## Usage++```haskell+import LoadEnv+import System.Environment (lookupEnv)++main :: IO ()+main = do+ loadEnv++ print =<< lookupEnv "FOO"+```++```console+% cat .env+FOO=bar+% runhaskell main.hs+Just "bar"+```++## Development & Test++```+stack setup+stack build --pedantic --test+```++---++[CHANGELOG](./CHANGELOG.md) | [LICENSE](./LICENSE)
load-env.cabal view
@@ -2,10 +2,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: b1f053dbd45894ad7e296e47dd667ef92f771066b17032b259e2f8d68b156898+-- hash: 2e4f7d0d54d77f91f6586cbaae5aef26c673de9f74d2d3b0447d42773e3630c0 name: load-env-version: 0.2.0.0+version: 0.2.0.1 synopsis: Load environment variables from a file. description: Parse a .env file and load any declared variables into the current process's environment. This allows for a .env file to specify development-friendly defaults for configuration values normally set in the deployment environment. category: Configuration@@ -17,6 +17,9 @@ license-file: LICENSE build-type: Simple cabal-version: >= 1.10+extra-source-files:+ CHANGELOG.md+ README.md source-repository head type: git
src/LoadEnv.hs view
@@ -2,16 +2,16 @@ -- -- This is effectively a port of dotenv, whose README explains it best: ----- /Storing configuration in the environment is one of the tenets of a--- twelve-factor app. Anything that is likely to change between deployment--- environments–such as resource handles for databases or credentials for--- external services–should be extracted from the code into environment--- variables./------ /But it is not always practical to set environment variables on development--- machines or continuous integration servers where multiple projects are run.--- dotenv loads variables from a .env file into ENV when the environment is--- bootstrapped./+-- > Storing configuration in the environment is one of the tenets of a+-- > twelve-factor app. Anything that is likely to change between deployment+-- > environments–such as resource handles for databases or credentials for+-- > external services–should be extracted from the code into environment+-- > variables.+-- >+-- > But it is not always practical to set environment variables on development+-- > machines or continuous integration servers where multiple projects are run.+-- > dotenv loads variables from a .env file into ENV when the environment is+-- > bootstrapped. -- -- <https://github.com/bkeepers/dotenv> --
test/LoadEnvSpec.hs view
@@ -39,6 +39,17 @@ lookupEnv "FOO" `shouldReturn` Just "bar" + it "loads only the nearest file" $ do+ inTempDirectory $ do+ writeFile ".env.test" "FOO=\"bar\"\n"+ inNewDirectory "foo/bar" $ do+ writeFile ".env.test" "BAR=\"baz\"\n"+ inNewDirectory "baz/bat" $ do+ loadEnvFrom ".env.test"++ lookupEnv "BAR" `shouldReturn` Just "baz"+ lookupEnv "FOO" `shouldReturn` Nothing+ describe "loadEnvFromAbsolute" $ do it "does not traverse up the directory tree" $ do inTempDirectory $ do