1.0.0 • Published 5 years ago

dynamic-dotenv v1.0.0

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

dynamic-dotenv

NPM Travis Codecov Greenkeeper badge David David Dev

Like dotenv, but dynamic!

Installing

# npm
npm install -s dynamic-dotenv

# yarn
yarn add dynamic-dotenv

Usage

This package essentially behaves the same as using the manual initialisation of the dotenv package. The main difference to dotenv, is that the response value is an EventEmitter. It will emit "change" events every time the loaded env file changes, as well as update the process.env values when that happens. If an error occurs, either from filesystem interaction or from dotenv, it will also be emitted as an "error" event.

import dynamicDotenv from 'dynamic-dotenv'

const dd = dynamicDotenv(/* you can pass the same options as dotenv here */)
// process.env now contains the values in your .env file

dd.on('change', () => {
  // this event will be emitted every time the .env file changes
})