Have ideas to improve npm?Join in the discussion! »

    @shopify/with-env
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.4 • Public • Published

    @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
      });
    });

    Keywords

    none

    Install

    npm i @shopify/with-env

    DownloadsWeekly Downloads

    31,507

    Version

    1.2.4

    License

    MIT

    Unpacked Size

    15 kB

    Total Files

    14

    Last publish

    Collaborators

    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar
    • avatar