1.0.0 • Published 8 years ago
isdebug v1.0.0
isDebug
isDebug is a simple module that returns true or false upon require.
If the result is true then the environment is a debug environment.
if the result is false then the environment is a production environment.
isDebug looks at two environment variables to determine the result:
NODE_ENV- If this environment variable begins with the string "dev" or "deb",
then the result will be
true
- If this environment variable begins with the string "dev" or "deb",
then the result will be
DEBUG- If this environment variable is set to anything, then the result will
be
true
- If this environment variable is set to anything, then the result will
be
If neither environment variable are present, then the result will be
false (i.e. a "production" environment).
Example
const isdebug = require('isdebug')
console.log('isdebug = %s', isdebug)Starting the above script with DEBUG=true node script.js
or NODE_ENV=development will result in:
isdebug = trueTo re-check the status, e.g. to determine if process.env has been manipulated,
simply re-require the module:
console.log('isdebug = %s', require('isdebug')) // false
process.env.NODE_ENV = 'development'
console.log('isdebug = %s', require('isdebug')) // true