1.0.2 • Published 2 years ago

yaml-env-load v1.0.2

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

yaml-env-load

NPM version

Loads config from yaml file to process.env. Unlike other packages, env can store objects.

Install

# with npm
npm install yaml-env-load

# or with Yarn
yarn add yaml-env-load

Usage

const config = require('yaml-env-load')
config('.env.yaml') // if no path is given, it defaults to .env 

env.yaml

NODE_ENV: production
db:
  host: localhost
  port: 27017

process.env now has the keys and values you defined in your .env.yaml file.

console.log(process.env.db) // returns { host: 'localhost', port: 27017 } AS OBJECT
console.log(process.env.NODE_ENV) // returns production AS STRING