https://github.com/ifreddyrondon/is-prod
Normalize the way of check if you are in a production env
https://github.com/ifreddyrondon/is-prod
development environment javascript nodejs production test
Last synced: 4 months ago
JSON representation
Normalize the way of check if you are in a production env
- Host: GitHub
- URL: https://github.com/ifreddyrondon/is-prod
- Owner: ifreddyrondon
- License: mit
- Created: 2017-06-04T16:26:46.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-08-05T11:12:15.000Z (almost 7 years ago)
- Last Synced: 2025-09-21T18:04:48.320Z (9 months ago)
- Topics: development, environment, javascript, nodejs, production, test
- Language: JavaScript
- Size: 9.77 KB
- Stars: 0
- Watchers: 0
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-prod
[](https://travis-ci.org/ifreddyrondon/is-prod)
[](https://codecov.io/gh/ifreddyrondon/is-prod)
[](https://www.npmjs.com/package/is-prod)
[](https://npm-stat.com/charts.html?package=is-prod&from=2017-05-27)
[](http://opensource.org/licenses/MIT)
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()