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

nodeenv

Package Overview
Dependencies
Maintainers
4
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodeenv - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

.eslintrc.json

42

lib/nodeenv.js
'use strict';
/*eslint-disable no-process-env*/
var nodeenv = function (key, value, callback) {
var backupValues,
environmentVariables;
/* eslint-disable no-process-env */
const nodeenv = function (key, value) {
let environmentVariables;
if (typeof key === 'string') {
if (typeof value === 'function') {
callback = value;
if (arguments.length === 1) {
value = key;
key = 'NODE_ENV';
} else if (typeof callback === 'undefined') {
throw new Error('Callback is missing.');
}

@@ -20,20 +16,16 @@

return nodeenv(environmentVariables, callback);
return nodeenv(environmentVariables);
}
if (typeof value === 'undefined') {
throw new Error('Callback is missing.');
}
environmentVariables = key;
callback = value;
backupValues = {};
Object.keys(environmentVariables).forEach(function (envKey) {
var envValue = environmentVariables[envKey];
const backupValues = {};
Object.keys(environmentVariables).forEach(envKey => {
const envValue = environmentVariables[envKey];
backupValues[envKey] = process.env[envKey];
if (envValue === undefined) {
delete process.env[envKey];
Reflect.deleteProperty(process.env, envKey);
} else {

@@ -44,15 +36,17 @@ process.env[envKey] = envValue;

callback(function () {
Object.keys(backupValues).forEach(function (backupKey) {
var backupValue = backupValues[backupKey];
const restore = function () {
Object.keys(backupValues).forEach(backupKey => {
const backupValue = backupValues[backupKey];
if (!backupValue) {
return delete process.env[backupKey];
Reflect.deleteProperty(process.env, backupKey);
}
process.env[backupKey] = backupValue;
});
});
};
return restore;
};
/*eslint-enable no-process-env*/
/* eslint-enable no-process-env */
module.exports = nodeenv;
{
"name": "nodeenv",
"version": "0.2.1",
"version": "0.3.0",
"description": "nodeenv enables tests to control Node.js environment variables.",

@@ -13,10 +13,14 @@ "contributors": [

"email": "matthias.wagler@thenativeweb.io"
},
{
"name": "Jan-Hendrik Grundhöfer",
"email": "jan-hendrik.grundhoefer@thenativeweb.io"
}
],
"main": "lib/nodeenv.js",
"main": "dist/nodeenv.js",
"dependencies": {},
"devDependencies": {
"assertthat": "0.4.2",
"grunt": "0.4.5",
"tourism": "0.13.2"
"assertthat": "0.10.3",
"roboter": "0.15.4",
"roboter-server": "0.15.4"
},

@@ -27,3 +31,7 @@ "repository": {

},
"keywords": [
"environment",
"nodeenv"
],
"license": "MIT"
}

@@ -7,3 +7,5 @@ # nodeenv

$ npm install nodeenv
```shell
$ npm install nodeenv
```

@@ -15,3 +17,3 @@ ## Quick start

```javascript
var nodeenv = require('nodeenv');
const nodeenv = require('nodeenv');
```

@@ -22,8 +24,9 @@

```javascript
nodeenv({
const restore = nodeenv({
NODE_ENV: 'dev'
}, function (restore) {
// ...
restore();
});
// ...
restore();
```

@@ -38,6 +41,7 @@

```javascript
nodeenv('NODE_ENV', 'dev', function (restore) {
// ...
restore();
});
const restore = nodeenv('NODE_ENV', 'dev');
// ...
restore();
```

@@ -50,6 +54,7 @@

```javascript
nodeenv('dev', function (restore) {
// ...
restore();
});
nodeenv('dev');
// ...
restore();
```

@@ -59,5 +64,7 @@

This module can be built using [Grunt](http://gruntjs.com/). Besides running the tests, this also analyses the code. To run Grunt, go to the folder where you have installed nodeenv and run `grunt`. You need to have [grunt-cli](https://github.com/gruntjs/grunt-cli) installed.
To build this module use [roboter](https://www.npmjs.com/package/roboter).
$ grunt
```shell
$ bot
```

@@ -67,3 +74,3 @@ ## License

The MIT License (MIT)
Copyright (c) 2013-2015 the native web.
Copyright (c) 2013-2017 the native web.

@@ -70,0 +77,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

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