is-prod

1.0.1 • Public • Published

is-prod

travis build codecov coverage version downloads MIT License

Normalize the way of check if you are in a production|development|test environment.

Just check NODE_ENV for common names pattern like dev for development or prod for production

const isProd = require('is-prod');

/**
 * Logger levels:
 *  error: 0
 *  warn: 1
 *  info: 2
 *  verbose: 3
 *  debug: 4
 *  silly: 5
 */

const loggerLevel;

if (isProd.isProduction()) {
  // do not log debug, just warn and up!
  loggerLevel = 'warn'
} else {
  loggerLevel = 'debug'
}

... 

// log the current normalized NODE_ENV
log.debug(isProd.getNormalizedEnv())

Check for production

Check the NODE_ENV for production or prod.

isProduction()

Check for devlopment

Check the NODE_ENV for devlopment or dev.

isDevelopment()

Check for test

Check the NODE_ENV for test.

isTest()

Get NODE_ENV

  1. Return the value of NODE_ENV.

    getEnv()

  2. Return the normalized word for NODE_ENV

    getNormalizedEnv()

Package Sidebar

Install

npm i is-prod

Weekly Downloads

3

Version

1.0.1

License

MIT

Last publish

Collaborators

  • ifreddyrondon