Socket
Socket
Sign inDemoInstall

getenv

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.3.0 to 0.4.0

test/fallbacks.js

14

lib/getenv.js
var util = require("util");
var fallbacksDisabled = false;
function _value(varName, fallback) {

@@ -10,2 +12,6 @@ var value = process.env[varName];

}
if (fallbacksDisabled) {
throw new Error('GetEnv.DisabledFallbacks: ' + varName + ' relying on fallback ' +
'when fallbacks have been disabled');
}
return '' + fallback;

@@ -102,2 +108,10 @@ }

getenv.disableFallbacks = function() {
fallbacksDisabled = true;
};
getenv.enableFallbacks = function() {
fallbacksDisabled = false;
};
module.exports = getenv;

5

package.json

@@ -8,5 +8,6 @@ {

"Jonas Dohse <jonas@dohse.ch>",
"Jan Lehnardt"
"Jan Lehnardt",
"Tim Ruffles <timruffles@gmail.com>"
],
"version": "0.3.0",
"version": "0.4.0",
"homepage": "https://github.com/ctavan/node-getenv",

@@ -13,0 +14,0 @@ "repository": {

@@ -101,4 +101,17 @@ # getenv

### env.disableFallbacks()
Disallows fallbacks in environments where you don't want to rely on brittle development defaults (e.g production, integration testing). For example, to disable fallbacks if we indicate production via `NODE_ENV`:
```javascript
if (process.env.NODE_ENV === 'production') {
getenv.disableFallbacks();
}
```
## Changelog
### v0.4.0
- Add getenv.disableFallbacks() support.
### v0.3.0

@@ -119,2 +132,3 @@ - Add getenv.multi() support.

- Jan Lehnardt (@janl): `getenv.multi()` support.
- Tim Ruffles <timruffles@gmail.com>: `disableFallbacks()`

@@ -121,0 +135,0 @@ ## License

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc