0.5.1 • Published 2 years ago

node-environment v0.5.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Code Style Publish to NPM

node-environment

Inspect or return the environment variable NODE_ENV

Requirements

node >=12

Features

  • Consult NODE_ENV known values (dev, development, production, prod)
  • Give development as default value
  • Return the raw value from NODE_ENV
  • All queries are case-insensitive

Installation

Install node-environment with npm

  npm install node-environment

Usage/Examples

Using CommonJS modules

const { env } = require('node-environment')

Using ECMAScript modules

import { env } from 'node-environment'
process.env.NODE_ENV = 'dev'

env('development') // true
env('staging', 'development') // true
env('test', 'production') // false
env() // "dev"

API Reference

The package only expose one function:

  env(): string
  env(query: string, ...otherEnvironments: string[]): boolean

Aliases:

prod == production

dev == development

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.

License

MIT