Simple module to test if current NODE_ENV is or is not within a list of allowed environments
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
LICENSE
README.md
index.d.ts
index.js
package.json

README.md

env-is

Simple module to test if current NODE_ENV is or is not within a list of allowed environments

Usage

It is simple as:

// for env = development
var env = require('env-is');

console.log(env.is('production')); // true if NODE_ENV is production
console.log(env.is(['production', 'staging'])); // true if NODE_ENV is production or staging

console.log(env.isNot('production')); // true if NODE_ENV is NOT production
console.log(env.isNot(['production', 'staging'])); // true if NODE_ENV is NOT production or staging

The return value of env.is will change depending on the value of NODE_ENV

NODE_ENV=production node app

Will return:

console.log(env.is('production')); //true
console.log(env.is(['production', 'staging'])); //true

console.log(env.isNot('production')); //false
console.log(env.isNot(['production', 'staging'])); //false

And

NODE_ENV=staging node app

Will return:

console.log(env.is('production')); //false
console.log(env.is(['production', 'staging'])); //true

console.log(env.isNot('production')); //true
console.log(env.isNot(['production', 'staging'])); //false

And...

NODE_ENV=development node app

Will return

console.log(env.is('production')); //false
console.log(env.is(['production', 'staging'])); //false

console.log(env.isNot('production')); //true
console.log(env.isNot(['production', 'staging'])); //true