Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

freeman-env

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

freeman-env

simple function wrapper for code to only be run in production or development

  • 1.0.6
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

freeman-env

Simple NPM wrapper for code that is only meant to be run in production/development.

This module tests the environment variable NODE_ENV - made popular by Express and other Node modules.

installation

npm install freeman-env --save

usage

process.env.NODE_ENV = "production";

var env = require('freeman-env');

//callback mode - run a code block only in certain environments
env('production', function(){
  console.log("This will only run in production.");
});

env('development', function(){
  console.log("This will only run in dev mode.");
});

//raw mode - simple getter for process.env.NODE_ENV
//use this for switch statements and more...
env(); //this will return 'production'

switch(env()){
  case "production":
    ...
  break;
  case "test":
    ...
  break;
  ...
}

notes

If you don't have process.env.NODE_ENV defined, nothing will happen.

You can define process.env.NODE_ENV to any string value and test against it. Here are some ideas: staging, test, development, etc.

Keywords

FAQs

Package last updated on 27 Jul 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc