New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@shopify/with-env

Package Overview
Dependencies
Maintainers
24
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@shopify/with-env

A utility for executing code under a specific `NODE_ENV`

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
24
Created
Source

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

FAQs

Package last updated on 10 Jun 2024

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