Library for resolving Environment variables.
Priority of Environment variables are (from the most important):
- environment variable (exported directly in script, or globally available)
- in the
.envfile
Add following into paket.references
Alma.Environment
open Alma.Environment
result {
do! Envs.loadResolvedFromFile "/file/path/.env" // load and resolve variables from file; existing env vars take priority
// or
do! Envs.forceLoadResolvedFromFile "/file/path/.env" // load and resolve variables from file; overrides existing env vars
}
|> ignore
let envs = Envs.getAll() // get all loaded variables
// create functions to find in environment keys
let tryGetEnv key = envs |> Map.tryFind key
let getEnv key = envs |> Map.find key
let optional = // string option
"OPTIONAL_ENV_VAR"
|> tryGetEnv
let optionalOrDefault = // string
"OPTIONAL_ENV_VAR"
|> tryGetEnv
|> function
| Some value -> value
| _ -> "default"
let mandatory = // string
"MANDATORY_ENV_VAR"
|> getEnv // or exception- Increment version in
Environment.fsproj - Update
CHANGELOG.md - Commit new version and tag it
./build.sh build./build.sh -t tests