Skip to content

A version of dotenv that will watch the dotenv file and reload it if it changes

License

Notifications You must be signed in to change notification settings

call-a3/dynamic-dotenv

Repository files navigation

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
})

About

A version of dotenv that will watch the dotenv file and reload it if it changes

Resources

License

Stars

Watchers

Forks

Packages

No packages published