@shopify/with-env
A utility for executing code under a specific `NODE_ENV`
Last updated 10 days ago by shopify-dep .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @shopify/with-env 
SYNC missed versions from official npm registry.

@shopify/with-env

Build Status License: MIT npm version

A utility for executing code under a specific NODE_ENV.

Installation

$ yarn add @shopify/with-env

Or, if you just need this for tests:

$ yarn add --dev @shopify/with-env

Example Usage

In this example, we are testing some code using Jest. Note that, while Jest is not required to use @shopify/with-env, it is our recommended testing framework for node and javascript applications.

import withEnv from '@shopify/with-env';

it('does one thing in development', () => {
  withEnv('development', () => {
    // your code here
  });
});

it('does another thing in production', () => {
  withEnv('production', () => {
    // your code here
  });
});

It also allows to change (and reset) multiple environment variables at once.

import withEnv from '@shopify/with-env';

it('does one thing', () => {
  withEnv({MY_ENV_ONE: 'test', ANOTHER_ENV: 'test-2'}, () => {
    // your code here
  });
});

Current Tags

  • 1.1.9                                ...           latest (10 days ago)

20 Versions

  • 1.1.9                                ...           10 days ago
  • 1.1.8                                ...           2 months ago
  • 1.1.7                                ...           3 months ago
  • 1.1.6                                ...           5 months ago
  • 1.1.5                                ...           6 months ago
  • 1.1.4                                ...           7 months ago
  • 1.1.3                                ...           8 months ago
  • 1.1.2                                ...           9 months ago
  • 1.1.1                                ...           10 months ago
  • 1.1.0                                ...           a year ago
  • 1.0.11                                ...           a year ago
  • 1.0.10                                ...           a year ago
  • 1.0.9                                ...           a year ago
  • 1.0.7                                ...           2 years ago
  • 1.0.6                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
  • 1.0.4                                ...           2 years ago
  • 1.0.3                                ...           2 years ago
  • 1.0.2                                ...           2 years ago
  • 1.0.1                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 9
Last Month 10
Dependencies (1)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2017 © taobao.org |