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

node-env-file

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-env-file - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

43

examples/basic.js

@@ -1,28 +0,29 @@

var assert = require('assert');
var env = require('../');
'use strict'
process.env.FOO = "defaultfoo";
var assert = require('assert')
var env = require('../')
process.env.FOO = "defaultfoo"
// Load any undefined ENV variables form a specified file.
env(__dirname + '/.env');
assert.equal(process.env.FOO, "defaultfoo");
assert.equal(process.env.BAR, "bar1");
assert.equal(process.env.BAZ, "1");
assert.equal(process.env.QUX, "");
env(__dirname + '/.env')
assert.equal(process.env.FOO, "defaultfoo")
assert.equal(process.env.BAR, "bar1")
assert.equal(process.env.BAZ, "1")
assert.equal(process.env.QUX, "")
// Load another ENV file - and overwrite any defined ENV variables.
env(__dirname + '/.env2', {overwrite: true});
assert.equal(process.env.FOO, "foo2");
assert.equal(process.env.BAR, "bar2");
assert.equal(process.env.BAZ, "2");
assert.equal(process.env.QUX, "");
env(__dirname + '/.env2', {overwrite: true})
assert.equal(process.env.FOO, "foo2")
assert.equal(process.env.BAR, "bar2")
assert.equal(process.env.BAZ, "2")
assert.equal(process.env.QUX, "")
console.log('=============');
console.log(' ENV');
console.log('----------');
console.log(env.data);
console.log('----------');
console.log('DONE');
console.log('=============')
console.log(' ENV')
console.log('----------')
console.log(env.data)
console.log('----------')
console.log('DONE')
process.exit();
process.exit()

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

'use strict'

@@ -6,2 +7,2 @@ // -----------------------

module.exports = require('./lib');
module.exports = require('./lib')

@@ -1,5 +0,5 @@

'use strict';
'use strict'
var fs = require('fs');
var path = require('path');
var fs = require('fs')
var path = require('path')

@@ -11,120 +11,143 @@ //----------------------

module.exports = function (env_file, options) {
options = options || {};
options = options || {}
if (typeof options.verbose === 'undefined') {
options.verbose = module.exports.verbose;
}
if (typeof options.verbose === 'undefined') {
options.verbose = module.exports.verbose
}
if (typeof options.overwrite === 'undefined') {
options.overwrite = module.exports.overwrite;
}
if (typeof options.raise === 'undefined') {
options.raise = module.exports.raise;
}
module.exports.logger = options.logger || module.exports.logger;
if (typeof env_file !== 'string') {
if (options.raise) {
throw new TypeError("Environment file argument is not a valid `String`: " + env_file);
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.error('[ENV]: ERROR Environment file argument is not a valid `String`:', process.env.ENV_FILE);
}
return {};
if (typeof options.overwrite === 'undefined') {
options.overwrite = module.exports.overwrite
}
}
try {
env_file = process.env.ENV_FILE = (path.resolve(env_file) || process.env.ENV_FILE);
} catch (err) {
if (options.raise) {
throw new TypeError("Environment file path could not be resolved: " + err);
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.error('[ENV]: ERROR Environment file path could not be resolved:', process.env.ENV_FILE);
}
return {};
if (typeof options.raise === 'undefined') {
options.raise = module.exports.raise
}
}
module.exports.data = module.exports.data || {};
module.exports.data[env_file] = {};
module.exports.logger = options.logger || module.exports.logger
if (options.verbose && module.exports.logger) {
module.exports.logger.info('[ENV]: Loading environment:', env_file);
}
if (typeof env_file !== 'string') {
if (options.raise) {
throw new TypeError("Environment file argument is not a valid `String`: " + env_file)
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.error('[ENV]: ERROR Environment file argument is not a valid `String`:', process.env.ENV_FILE)
}
return {}
}
}
if (fs.existsSync(env_file)) {
var lines;
try {
lines = fs.readFileSync(env_file, 'utf8').match(/([\w+]+)\s*\=(\n|.*)/gmi) || [];
env_file = process.env.ENV_FILE = path.resolve(env_file) || process.env.ENV_FILE
} catch (err) {
if (options.raise) {
throw new TypeError("Environment file could not be read: " + err);
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.error('[ENV]: ERROR Environment file could not be read:', env_file);
if (options.raise) {
throw new TypeError("Environment file path could not be resolved: " + err)
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.error('[ENV]: ERROR Environment file path could not be resolved:', process.env.ENV_FILE)
}
return {}
}
return {};
}
}
lines.forEach(function(line) {
if (!/^\s*\#/i.test(line)) { // ignore comment lines (starting with #).
var key_value = line.match(/^([^=]+)\s*=\s*(.*)$/);
module.exports.data = module.exports.data || {}
module.exports.data[env_file] = {}
var env_key = key_value[1];
if (options.verbose && module.exports.logger) {
module.exports.logger.info('[ENV]: Loading environment:', env_file)
}
// remove ' and " characters if right side of = is quoted
var env_value = key_value[2].match(/^(['"]?)([^\n]*)\1$/m)[2];
if (fs.existsSync(env_file)) {
var lines
// overwrite already defined `process.env.*` values?
if (!!options.overwrite) {
module.exports.data[env_file][env_key] = env_value;
try {
// lines = fs.readFileSync(env_file, 'utf8').match(/((?:\s*\#\s*)?.*[\w+]+)\s*\=(\n|.*)/gmi) || []
lines = (fs.readFileSync(env_file, 'utf8') || '')
.split("\n")
.filter(function (line) {
return /\s*=\s*/i.test(line)
})
.map(function (line) {
return line.replace('exports ', '')
})
if (options.verbose && module.exports.logger && module.exports.data[env_file][env_key] !== env_value) {
module.exports.logger.info('[ENV]: Overwritten ', module.exports.data[env_file][env_key], ' => ', env_value);
}
} catch (err) {
if (options.raise) {
throw new TypeError("Environment file could not be read: " + err)
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.error('[ENV]: ERROR Environment file could not be read:', env_file)
}
return {}
}
}
else {
module.exports.data[env_file][env_key] = (process.env[env_key] || env_value);
}
process.env[env_key] = module.exports.data[env_file][env_key];
module.exports.lines = module.exports
module.exports.lines.comments = []
module.exports.lines.variables = []
if (options.verbose && module.exports.logger) {
module.exports.logger.info('[ENV]:', module.exports.data[env_file]);
var is_comment
lines.forEach(function(line) {
is_comment = /^\s*\#/i.test(line) // ignore comment lines (starting with #).
if (is_comment) {
module.exports.lines.comments.push(line)
if (options.verbose && module.exports.logger) {
module.exports.logger.info('[ENV]: Ignored line:', line)
}
} else {
module.exports.lines.variables.push(line)
var key_value = line.match(/^([^=]+)\s*=\s*(.*)$/)
var env_key = key_value[1]
// remove ' and " characters if right side of = is quoted
var env_value = key_value[2].match(/^(['"]?)([^\n]*)\1$/m)[2]
// overwrite already defined `process.env.*` values?
if (!!options.overwrite) {
module.exports.data[env_file][env_key] = env_value
if (options.verbose && module.exports.logger && module.exports.data[env_file][env_key] !== env_value) {
module.exports.logger.info('[ENV]: Overwritten ', module.exports.data[env_file][env_key], ' => ', env_value)
}
} else {
module.exports.data[env_file][env_key] = process.env[env_key] || env_value
}
process.env[env_key] = module.exports.data[env_file][env_key]
if (options.verbose && module.exports.logger) {
module.exports.logger.info('[ENV]:', module.exports.data[env_file])
}
}
})
}
else {
if (options.raise) {
throw new TypeError("Environment file doesn't exist: " + env_file)
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.error('[ENV]: ERROR Environment file path could not be resolved:', env_file)
}
return {}
}
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.info('[ENV]: Ignored line:', line);
}
}
});
}
else {
if (options.raise) {
throw new TypeError("Environment file doesn't exist: " + env_file);
} else {
if (options.verbose && module.exports.logger) {
module.exports.logger.error('[ENV]: ERROR Environment file path could not be resolved:', env_file);
}
return {};
}
}
return module.exports.data[env_file];
};
return module.exports.data[env_file]
}
module.exports.log = false;
module.exports.logger = console;
module.exports.overwrite = false;
module.exports.raise = true;
module.exports.data = {};
module.exports.log = false
module.exports.logger = console
module.exports.overwrite = false
module.exports.raise = true
module.exports.data = {}
module.exports.sync = module.exports;
module.exports.sync = module.exports
// TODO: module.exports.async = module.exports.async;
// TODO: module.exports.async = module.exports.async

@@ -5,3 +5,3 @@ {

"keywords": ["process", "env", "file", "files", ".env", "ENV", "process.env", "parse", "load", "export", "exports"],
"version": "0.1.5",
"version": "0.1.6",
"homepage": "https://github.com/grimen/node-env-file",

@@ -8,0 +8,0 @@ "repository": {

@@ -1,9 +0,11 @@

process.env.NODE_ENV = 'test';
'use strict'
module.exports.chai = require('chai');
module.exports.chai.Assertion.includeStack = true;
process.env.NODE_ENV = 'test'
module.exports.assert = module.exports.chai.assert;
module.exports.expect = module.exports.chai.expect;
module.exports.chai = require('chai')
module.exports.chai.config.includeStack = true
module.exports.debug = console.log;
module.exports.assert = module.exports.chai.assert
module.exports.expect = module.exports.chai.expect
module.exports.debug = console.log

@@ -1,8 +0,10 @@

var helper = require('./helper'),
assert = helper.assert,
expect = helper.expect,
debug = helper.debug;
'use strict'
var env = require('../');
var helper = require('./helper')
var assert = helper.assert
var expect = helper.expect
var debug = helper.debug
var env = require('../')
// -----------------------

@@ -14,294 +16,349 @@ // Test

before: function() {
expect(env).to.be.a('function');
},
before: function() {
expect(env).to.be.a('function')
},
'beforeEach': function() {
delete process.env.FOO;
delete process.env.BAR;
delete process.env.BAZ;
delete process.env.QUX;
delete process.env.NORF;
},
'beforeEach': function() {
delete process.env.FOO
delete process.env.BAR
delete process.env.BAZ
delete process.env.QUX
delete process.env.NORF
delete process.env.IGNORE
},
'()': function() {
expect(function() {
env();
}).to.throw(TypeError);
},
'()': function() {
expect(function() {
env()
}).to.throw(TypeError)
// non-existing
expect(function() {
env(__dirname + '/fixtures/.env.100', {raise: false})
}).to.not.throw(Error)
},
'(<non_existing_file>, [<options>])': {
'("./fixtures/.env.100")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.100');
}).to.throw(Error);
// non-existing
expect(process.env.FOO).to.be.equal(undefined);
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
'(<non_existing_file>, [<options>])': {
'("./fixtures/.env.100")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.100')
}).to.throw(Error)
process.env.FOO = 'foo2';
expect(process.env.FOO).to.be.equal(undefined)
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(function() {
env(__dirname + '/fixtures/.env.100', {});
}).to.throw(Error);
process.env.FOO = 'foo2'
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(function() {
env(__dirname + '/fixtures/.env.100', {})
}).to.throw(Error)
process.env.FOO = 'foo2';
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(function() {
env(__dirname + '/fixtures/.env.100', {overwrite: true});
}).to.throw(Error);
process.env.FOO = 'foo2'
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
}
},
expect(function() {
env(__dirname + '/fixtures/.env.100', {overwrite: true})
}).to.throw(Error)
'(<existing_file>, [<options>])': {
'("./fixtures/.env.0")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.0');
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal(undefined);
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(function() {
env(__dirname + '/fixtures/.env.100', {raise: false})
}).to.not.throw(Error)
}
},
process.env.FOO = 'foo2';
'(<existing_file>, [<options>])': {
'("./fixtures/.env.0")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.0')
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.0', {});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal(undefined)
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
process.env.FOO = 'foo2'
process.env.FOO = 'foo2';
expect(function() {
env(__dirname + '/fixtures/.env.0', {})
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.0', {overwrite: true});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
},
process.env.FOO = 'foo2'
'("./fixtures/.env.1")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.1');
}).to.not.throw(Error);
expect(function() {
env(__dirname + '/fixtures/.env.0', {overwrite: true})
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
},
process.env.FOO = 'foo2';
'("./fixtures/.env.1")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.1')
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.1', {});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('1')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
process.env.FOO = 'foo2'
process.env.FOO = 'foo2';
expect(function() {
env(__dirname + '/fixtures/.env.1', {})
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.1', {overwrite: true});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
},
process.env.FOO = 'foo2'
'("./fixtures/.env.2")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.2');
}).to.not.throw(Error);
expect(function() {
env(__dirname + '/fixtures/.env.1', {overwrite: true})
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');
expect(process.env.FOO).to.be.equal('1')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
},
process.env.FOO = 'foo2';
'("./fixtures/.env.2")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.2')
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.2', {});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('1')
expect(process.env.BAR).to.be.equal('bar')
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal('')
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');
process.env.FOO = 'foo2'
process.env.FOO = 'foo2';
expect(function() {
env(__dirname + '/fixtures/.env.2', {})
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.2', {overwrite: true});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal('bar')
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal('')
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');
},
process.env.FOO = 'foo2'
'("./fixtures/.env.3")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.3');
}).to.not.throw(Error);
expect(function() {
env(__dirname + '/fixtures/.env.2', {overwrite: true})
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('http://foo.com?bar=baz');
},
expect(process.env.FOO).to.be.equal('1')
expect(process.env.BAR).to.be.equal('bar')
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal('')
expect(process.env.IGNORE).to.be.equal(undefined)
},
'("./fixtures/.env.4")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.4');
}).to.not.throw(Error);
'("./fixtures/.env.3")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.3')
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('http://foo.com#hash?bar=baz');
},
expect(process.env.FOO).to.be.equal('http://foo.com?bar=baz')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
},
'("./fixtures/.env.4")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.4')
}).to.not.throw(Error)
'("./fixtures/.env.5")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.5');
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('http://foo.com#hash?bar=baz')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
},
expect(process.env.FOO).to.be.equal('');
expect(process.env.BAR).to.be.equal('1');
expect(process.env.BAZ).to.be.equal('');
expect(process.env.QUX).to.be.equal('sample');
expect(process.env.NORF).to.be.equal('');
},
'("./fixtures/.env.exports.0")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.0');
}).to.not.throw(Error);
'("./fixtures/.env.5")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.5')
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal(undefined);
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.FOO).to.be.equal('')
expect(process.env.BAR).to.be.equal('1')
expect(process.env.BAZ).to.be.equal('')
expect(process.env.QUX).to.be.equal('sample')
expect(process.env.NORF).to.be.equal('')
expect(process.env.IGNORE).to.be.equal(undefined)
},
process.env.FOO = 'foo2';
'("./fixtures/.env.exports.0")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.0')
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.exports.0', {});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal(undefined)
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
process.env.FOO = 'foo2'
process.env.FOO = 'foo2';
expect(function() {
env(__dirname + '/fixtures/.env.exports.0', {})
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.exports.0', {overwrite: true});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
},
process.env.FOO = 'foo2'
'("./fixtures/.env.exports.1")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.1');
}).to.not.throw(Error);
expect(function() {
env(__dirname + '/fixtures/.env.exports.0', {overwrite: true})
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
},
process.env.FOO = 'foo2';
'("./fixtures/.env.exports.1")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.1')
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.exports.1', {});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('1')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
process.env.FOO = 'foo2'
process.env.FOO = 'foo2';
expect(function() {
env(__dirname + '/fixtures/.env.exports.1', {})
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.exports.1', {overwrite: true});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal(undefined);
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal(undefined);
},
process.env.FOO = 'foo2'
'("./fixtures/.env.exports.2")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.2');
}).to.not.throw(Error);
expect(function() {
env(__dirname + '/fixtures/.env.exports.1', {overwrite: true})
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');
expect(process.env.FOO).to.be.equal('1')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
},
process.env.FOO = 'foo2';
'("./fixtures/.env.exports.2")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.2')
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.exports.2', {});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('1')
expect(process.env.BAR).to.be.equal('bar')
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal('')
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('foo2');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');
process.env.FOO = 'foo2'
process.env.FOO = 'foo2';
expect(function() {
env(__dirname + '/fixtures/.env.exports.2', {})
}).to.not.throw(Error)
expect(function() {
env(__dirname + '/fixtures/.env.exports.2', {overwrite: true});
}).to.not.throw(Error);
expect(process.env.FOO).to.be.equal('foo2')
expect(process.env.BAR).to.be.equal('bar')
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal('')
expect(process.env.IGNORE).to.be.equal(undefined)
expect(process.env.FOO).to.be.equal('1');
expect(process.env.BAR).to.be.equal('bar');
expect(process.env.BAZ).to.be.equal(undefined);
expect(process.env.QUX).to.be.equal('');
},
process.env.FOO = 'foo2'
'("./fixtures/.env.exports.3")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.3');
}).to.not.throw(Error);
expect(function() {
env(__dirname + '/fixtures/.env.exports.2', {overwrite: true})
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('http://foo.com?bar=baz');
expect(process.env.FOO).to.be.equal('1')
expect(process.env.BAR).to.be.equal('bar')
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal('')
expect(process.env.IGNORE).to.be.equal(undefined)
},
'("./fixtures/.env.exports.3")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.3')
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('http://foo.com?bar=baz')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
},
'("./fixtures/.env.exports.4")': function () {
expect(function() {
env(__dirname + '/fixtures/.env.exports.4')
}).to.not.throw(Error)
expect(process.env.FOO).to.be.equal('http://foo.com#hash?bar=baz')
expect(process.env.BAR).to.be.equal(undefined)
expect(process.env.BAZ).to.be.equal(undefined)
expect(process.env.QUX).to.be.equal(undefined)
expect(process.env.IGNORE).to.be.equal(undefined)
}
}
}
};
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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