Comparing version 1.0.1 to 1.0.2
@@ -0,4 +1,5 @@ | ||
var proc = typeof process === 'object' && process ? process : { env: {} } | ||
var ownOr = require('own-or') | ||
module.exports = function ownOrEnv (object, field, env, bool) { | ||
var res = ownOr(object, field, process.env[env]) | ||
var res = ownOr(object, field, proc.env[env]) | ||
if (bool) | ||
@@ -5,0 +6,0 @@ res = !!+(res) |
{ | ||
"name": "own-or-env", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Use an objects own property, or an environment variable. Optionally treat as a boolean if the env should be set to 1 or 0.", | ||
@@ -5,0 +5,0 @@ "main": "own-or-env.js", |
21
test.js
@@ -16,2 +16,23 @@ var assert = require('assert') | ||
var proc = global.process | ||
global.process = null | ||
assert.equal(ownOrEnv(conf, 't', 'OWN_OR_BOOL_FALSE', true), true) | ||
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_BOOL_FALSE', true), false) | ||
assert.equal(ownOrEnv(conf, 'f', 'OWN_OR_BOOL_TRUE', true), false) | ||
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_BOOL_TRUE', true), true) | ||
assert.equal(ownOrEnv(conf, 's', 'OWN_OR_STRING'), 'bar') | ||
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_STRING'), 'foo') | ||
global.process = proc | ||
delete require.cache[require.resolve('./')] | ||
global.process = null | ||
ownOrEnv = require('./') | ||
assert.equal(ownOrEnv(conf, 't', 'OWN_OR_BOOL_FALSE', true), true) | ||
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_BOOL_FALSE', true), false) | ||
assert.equal(ownOrEnv(conf, 'f', 'OWN_OR_BOOL_TRUE', true), false) | ||
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_BOOL_TRUE', true), false) | ||
assert.equal(ownOrEnv(conf, 's', 'OWN_OR_STRING'), 'bar') | ||
assert.equal(ownOrEnv(conf, 'x', 'OWN_OR_STRING'), undefined) | ||
global.process = proc | ||
console.log('TAP version 13\nok\n1..1') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
6517
40
3