envdotyml

1.2.3 • Public • Published

envdotyml

npm CI Status dependencies Status devDependencies Status

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.

Readme

Keywords

none

Package Sidebar

Install

npm i envdotyml

Weekly Downloads

66

Version

1.2.3

License

MIT

Unpacked Size

4.36 kB

Total Files

6

Last publish

Collaborators

  • vinsonchuong