Comparing version 1.2.1 to 2.0.0
@@ -15,5 +15,3 @@ var through = require('through') | ||
var buffer = [] | ||
var env = argv | ||
? xtend(rootEnv, argv) | ||
: rootEnv | ||
argv = argv || {} | ||
@@ -31,3 +29,4 @@ return through(write, flush) | ||
try { | ||
source = jstransform.transform(createVisitors(env), source).code | ||
var visitors = createVisitors([argv, rootEnv]) | ||
source = jstransform.transform(visitors, source).code | ||
} catch(err) { | ||
@@ -34,0 +33,0 @@ return this.emit('error', err) |
{ | ||
"name": "envify", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "Selectively replace Node-style environment variables with plain strings.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
23
test.js
@@ -102,1 +102,24 @@ var envify = require('./custom') | ||
}) | ||
test('Handles getter properties', function(t) { | ||
var env = {} | ||
var buffer = '' | ||
var stream = envify(env) | ||
var counter = 0 | ||
Object.defineProperty(env, 'DYNAMIC', { | ||
// please don't actually do this: | ||
get: function() { return counter++ ? 'really!' : 'dynamic!' } | ||
}) | ||
stream().on('data', function(d) { buffer += d }) | ||
.on('end', function() { | ||
t.notEqual(-1, buffer.indexOf('foo = "dynamic!"')) | ||
t.notEqual(-1, buffer.indexOf('bar = "really!"')) | ||
t.end() | ||
}) | ||
.end([ | ||
'var foo = process.env.DYNAMIC' | ||
, 'var bar = process.env.DYNAMIC' | ||
].join('\n')) | ||
}) |
var Syntax = require('esprima-fb').Syntax | ||
var utils = require('jstransform/src/utils') | ||
function create(env) { | ||
function create(envs) { | ||
function visitProcessEnv(traverse, node, path, state) { | ||
var key = node.property.name | ||
if (env[key] !== undefined) { | ||
utils.catchup(node.range[0], state) | ||
utils.append(JSON.stringify(env[key]), state) | ||
utils.move(node.range[1], state) | ||
for (var i = 0; i < envs.length; i++) { | ||
var value = envs[i][key] | ||
if (value !== undefined) { | ||
utils.catchup(node.range[0], state) | ||
utils.append(JSON.stringify(value), state) | ||
utils.move(node.range[1], state) | ||
return false | ||
} | ||
} | ||
return false | ||
@@ -14,0 +20,0 @@ } |
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
9095
175