3.0.1 • Published 2 years ago

@shopify/with-env v3.0.1

Weekly downloads
31,994
License
MIT
Repository
github
Last release
2 years ago

@shopify/with-env

Build Status 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
  });
});
3.0.1

2 years ago

3.0.0

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.4

3 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.10

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago