1.2.3 • Published 3 years ago

envdotyml v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

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.

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago