asenv
NODE_ENV accessor
Installation
$ npm install asenv --save
Usage
'use strict'
const { getEnv, setEnv, isProduction } = require('asenv')
{
let env = getEnv()
console.log('env=', env)
/* ... */
setEnv('production')
/* ... */
if (isProduction()) {
/* ... */
}
}
Functions
Available functions
Signature | Description |
---|---|
.getEnv()() -> ?string |
Get NODE_ENV value |
.isDevelopment() -> boolean |
Check if the env it development |
.isProduction() -> boolean |
Check if the env is production |
.isTest() -> boolean |
Check if the env is test |
.setEnv()(env) |
Set NODE_ENV value |
.unlessProduction(handler) |
Do unless production |
License
This software is released under the MIT License.