🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

default-env

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

default-env

Composable cascading environment variable defaults

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

defaultEnv

Composable cascading environment variable defaults.

NPM version Build Status MIT License

The environments your app runs in don't divide into neat buckets like development, staging, and production. Your client side unit tests shouldn't spend time minifying. Your integration tests should. You always minify in production. Your continuous integration host doesn't install the browser that gives you nice test failure debugging in development, but sometimes you want to run those just like CI, because they fail there but pass on your machine.

Instead of coding all those configuration rules into your app, layer on additive environments. Define your environments near eachother, so the composition is easy to reason about.

Variables explicitly set in the environment always have final say.

Usage

npm install default-env
var defaultEnv = require('default-env')

defaultEnv.define({
  test: {
    PORT: 4001,
    LOG_LEVEL: 'error',
    OPTIMIZE: false
  },
  integration: {
    OPTIMIZE: true
  },
  development: {
    OPTIMIZE: false,
    PORT: 4000,
    LOG_LEVEL: 'warning'
  },
  production: {
    OPTIMIZE: true,
    LOG_LEVEL: 'verbose'
  }
})

task('test:integation', function() {
  defaultEnv.use('test', 'integration')
  // ...
})

See tests for more examples.

Contributing

Please follow our Code of Conduct when contributing to this project.

$ git clone https://github.com/goodeggs/default-env && cd default-env
$ npm install
$ npm test

Module scaffold generated by generator-goodeggs-npm.

Keywords

environment

FAQs

Package last updated on 12 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts