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 3.1.0 to 3.2.0

.npmignore

2

package.json
{
"name": "envify",
"version": "3.1.0",
"version": "3.2.0",
"description": "Selectively replace Node-style environment variables with plain strings.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -107,2 +107,33 @@ # 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) #

## Purging `process.env` ##
By default, environment variables that are not defined will be left untouched.
This is because in some cases, you might want to run an envify transform over
your source more than once, and removing these values would make that
impossible.
However, if any references to `process.env` are remaining after transforming
your source with envify, browserify will automatically insert its shim for
Node's process object, which will increase the size of your bundle. This weighs
in at around 2KB, so if you're trying to be conservative with your bundle size
you can "purge" these remaining variables such that any missing ones are simply
replaced with undefined.
To do so through the command-line, simply use the subarg syntax and include
`purge` after `envify`, e.g.:
``` bash
browserify index.js -t [ envify purge --NODE_ENV development ]
```
Or if you're using the module API, you can pass `_: "purge"` into your
arguments like so:
``` javascript
b.transform(envify({
_: 'purge'
, NODE_ENV: 'development'
}))
```
## Contributors ##

@@ -109,0 +140,0 @@

@@ -5,2 +5,4 @@ var Syntax = require('jstransform').Syntax

function create(envs) {
var args = [].concat(envs[0]._ || []).concat(envs[1]._ || [])
var purge = args.indexOf('purge') !== -1

@@ -13,5 +15,3 @@ function visitProcessEnv(traverse, node, path, state) {

if (value !== undefined) {
utils.catchup(node.range[0], state)
utils.append(JSON.stringify(value), state)
utils.move(node.range[1], state)
replaceEnv(node, state, value)
return false

@@ -21,5 +21,15 @@ }

if (purge) {
replaceEnv(node, state, undefined)
}
return false
}
function replaceEnv(node, state, value) {
utils.catchup(node.range[0], state)
utils.append(JSON.stringify(value), state)
utils.move(node.range[1], state)
}
visitProcessEnv.test = function(node, path, state) {

@@ -26,0 +36,0 @@ return (

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