Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

envify

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

envify - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

.travis.yml

72

custom.js
var through = require('through')
, falafel = require('falafel')
, recast = require('recast')
, n = recast.types.namedTypes
, b = recast.types.builders
, traverse = recast.types.traverse
, processEnvPattern = /\bprocess\.env\b/
module.exports = function(env) {
env = env || process.env || {}
return envify
function envify(file) {
if (/\.json$/.test(file)) return through();
return function envify(file) {
if (/\.json$/.test(file)) return through()
var buffer = ''
var buffer = []
return through(function(data) {
buffer += data
buffer.push(data)
}, function processFile() {
var output = falafel(buffer, function(node) {
if (!(
node.type === 'Identifier' &&
node.name === 'process' &&
node.parent &&
node.parent.property &&
node.parent.property.type === 'Identifier' &&
node.parent.property.name === 'env' &&
node.parent.parent &&
node.parent.parent.property &&
( node.parent.parent.property.name ||
node.parent.parent.property.value ) &&
(!node.parent.parent.parent
? true
:!(
node.parent.parent.parent.type === 'AssignmentExpression' &&
node.parent.parent.parent.left.type === 'MemberExpression' &&
node.parent.parent.parent.left.object.object &&
node.parent.parent.parent.left.object.object.name === 'process'
)))) return
var source = buffer.join('')
var key = node.parent.parent.property.name ||
node.parent.parent.property.value
if (processEnvPattern.test(source)) {
var ast = recast.parse(source)
if (!(key in env)) return
traverse(ast, function(node) {
if (
n.MemberExpression.check(node)
&& !node.computed
&& n.Identifier.check(node.property)
&& n.MemberExpression.check(node.object)
&& n.Identifier.check(node.object.object)
&& node.object.object.name === 'process'
&& n.Identifier.check(node.object.property)
&& node.object.property.name === 'env'
) {
var key = node.property.name
if (key in env) {
this.replace(b.literal(env[key]))
return false
}
}
});
node.parent.parent.update(
env[key] ? JSON.stringify(env[key]) :
env[key] === false ? 'false' :
env[key] === null ? 'null' :
env[key] === '' ? '""' :
env[key] === 0 ? '0' :
'undefined'
)
})
source = recast.print(ast).code
}
this.queue(String(output))
this.queue(source)
this.queue(null)

@@ -54,0 +48,0 @@ })

{
"name": "envify",
"version": "0.2.0",
"version": "1.0.0",
"description": "Selectively replace Node-style environment variables with plain strings.",

@@ -19,7 +19,7 @@ "main": "index.js",

"devDependencies": {
"tape": "~0.3.3"
"tape": "~2.3.2"
},
"dependencies": {
"through": "~2.3.4",
"falafel": "~0.2.1"
"recast": "~0.5.6"
},

@@ -26,0 +26,0 @@ "keywords": [

@@ -1,2 +0,2 @@

# envify #
# envify [![Build Status](https://secure.travis-ci.org/hughsk/envify.png?branch=master)](http://travis-ci.org/hughsk/envify) [![stable](http://hughsk.github.io/stability-badges/dist/stable.svg)](http://github.com/hughsk/stability-badges) #

@@ -79,3 +79,3 @@ Selectively replace Node-style environment variables with plain strings.

var bundle = browserify('main.js')
var b = browserify('main.js')
, output = fs.createWriteStream('bundle.js')

@@ -82,0 +82,0 @@

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