getenv
Advanced tools
Comparing version 0.3.0 to 0.4.0
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; |
@@ -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 |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
20272
8
522
136
37