envdotyml
v1.2.3
Published
Load environment variables from a .env.yml file
Downloads
292
Readme
envdotyml
Load environment variables from a .env.yml
file
Usage
Install envdotyml by running:
yarn add envdotyml
Then, at the top of a file that will be executed before you access any environment variables, add:
import 'envdotyml/set.js'
Alternatively, for more control over when environment variables are set:
import {parse, set} from 'envdotyml'
async function run() {
// Reads environment variables and mutates `process.env`
await set()
// Returns the environment variables without mutating `process.env`
const vars = await parse()
}
run()
The .env.yml
is expected to be an associative array:
STRING: Hello World!
MULTILINE_STRING: |
foo
bar
baz
ARRAY:
- One
- Two
- Three
OBJECT:
key: value
Strings are left as is. More complex values are converted to JSON strings.
If .env.yml
does not exist, parse
will return an empty object, and set
will do nothing.