1.2.3 • Published 4 years ago
envdotyml v1.2.3
envdotyml
Load environment variables from a .env.yml file
Usage
Install envdotyml by running:
yarn add envdotymlThen, 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: valueStrings 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.