You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

env-restorer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

env-restorer

Automatically snapshots and restores environment variables

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

Build Status npm version

env-restorer

Utility that snapshots the environment variables from process.env and can restore them on demand. Initially developed for testing vandium.

Features

  • Automatically snapshots environment variable state
  • Nested snapshots are allowed
  • No dependencies

Installation

Install via npm.

npm install env-restorer

Getting Started

A snapshot of the environment variables is created automatically when the library is loaded.

const envRestorer = require( 'env-restorer' );

// change environment variables
process.env.MY_SPECIAL_VALUE = '42';

envRestorer.restore();
// restore environment variables back to initial state (MY_SPECIAL_VALUE will no longer exist)

To create another snapshot of the environment variables state, simply call snapshot():

const envRestorer = require( 'env-restorer' );

// change environment variables
process.env.MY_SPECIAL_VALUE = '42';

const snapshot = envRestorer.snapshot();

// change environment variables
process.env.MY_SPECIAL_VALUE = '43';

snapshot.restore();
// process.env.MY_SPECIAL_VALUE will now equal '42'

envRestorer.restore();
// restore environment variables back to initial state (MY_SPECIAL_VALUE will no longer exist)

Feedback

We'd love to get feedback on how to make this tool better. Feel free to contact us at feedback@vandium.io

License

BSD-3-Clause

Keywords

environment

FAQs

Package last updated on 15 May 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