Socket
Socket
Sign inDemoInstall

dotenv

Package Overview
Dependencies
Maintainers
3
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dotenv - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

.editorconfig

15

lib/main.js

@@ -68,3 +68,3 @@ "use strict";

}
keys_and_values = dotenv.parse( data );

@@ -88,3 +88,3 @@ for( var key in keys_and_values ) {

parse : function(data) {
var keys_and_values;
var keys_and_values;
var payload = {};

@@ -103,7 +103,8 @@ var lines = dotenv._splitMultilineString( data.toString() );

load: function() {
dotenv._loadEnv();
dotenv._loadEnvDotEnvironment();
dotenv._setEnvs();
return true;
if (dotenv._loadEnv() && dotenv._loadEnvDotEnvironment()) {
dotenv._setEnvs();
return true;
} else {
return false;
}
},

@@ -110,0 +111,0 @@ };

{
"name": "dotenv",
"version": "0.4.0",
"version": "0.5.0",
"description": "Loads environment variables from .env",

@@ -10,3 +10,3 @@ "main": "lib/main.js",

"scripts": {
"test": "./node_modules/.bin/mocha test/*.js"
"test": "mocha test/*.js"
},

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

# dotenv
Dotenv loads environment variables from .env into ENV (process.env). It is a superior alternative to [nconf](https://github.com/flatiron/nconf) and other variants.
<img src="https://raw.githubusercontent.com/motdotla/dotenv/master/dotenv.png" alt="dotenv" align="right" />
[![BuildStatus](https://travis-ci.org/scottmotte/dotenv.png?branch=master)](https://travis-ci.org/scottmotte/dotenv)
Dotenv loads environment variables from `.env` into `ENV` (process.env).
[![BuildStatus](https://travis-ci.org/motdotla/dotenv.png?branch=master)](https://travis-ci.org/motdotla/dotenv)
[![NPM version](https://badge.fury.io/js/dotenv.png)](http://badge.fury.io/js/dotenv)
> "Storing [configuration in the environment](http://www.12factor.net/config) is one of the tenets of a [twelve-factor app](http://www.12factor.net/). Anything that is likely to change between deployment environments–such as resource handles for databases or credentials for external services–should be extracted from the code into environment variables.
>
> But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Dotenv load variables from a `.env` file into ENV when the environment is bootstrapped."
>
>
> But it is not always practical to set environment variables on development machines or continuous integration servers where multiple projects are run. Dotenv loads variables from a `.env` file into ENV when the environment is bootstrapped."
>
> [Brandon Keepers' Dotenv in Ruby](https://github.com/bkeepers/dotenv)

@@ -23,3 +25,3 @@

...
"dotenv": "0.4.0"
"dotenv": "0.5.0"
}

@@ -31,3 +33,3 @@ }

As early as possible in your application require dotenv and load the `.env` variables:
As early as possible in your application require dotenv and load the `.env` variables:

@@ -63,3 +65,3 @@ ```javascript

var dotenv = require('dotenv');
dotenv._getKeyAndValueFromLine('/custom/path/to/your/.env');
dotenv._getKeysAndValuesFromEnvFilePath('/custom/path/to/your/.env');
dotenv._setEnvs();

@@ -72,3 +74,3 @@ ```

Also added in `0.2.6` the method `parse` has been exposed. This is how `dotenv` internally parses multiline buffers or strings into an object to place into the `process.env` object.
Also added in `0.2.6` the method `parse` has been exposed. This is how `dotenv` internally parses multiline buffers or strings into an object to place into the `process.env` object.

@@ -82,2 +84,6 @@ ```javascript

### Dotenv.load
Added in `0.5.0`, the method `load` returns a boolean to indicate your .env file has been loaded without error. The most likely cause of error is not finding or reading your .env file(s).
## Should I commit my .env file?

@@ -104,3 +110,3 @@

Here's a list of apps/sites/libraries using dotenv. It's in no way a complete list.
Here's a list of apps/sites/libraries using dotenv. It's in no way a complete list.

@@ -111,6 +117,6 @@ * [sendgrid-nodejs](https://github.com/sendgrid/sendgrid-nodejs)

* [google-oauth2-service-account](https://github.com/jacoblwe20/google-oauth2-service-account)
* [kibble](https://github.com/scottmotte/kibble)
* [flossedtoday](https://github.com/scottmotte/flossedtoday)
* [github-streaker](https://github.com/scottmotte/github-streaker)
* [kibble](https://github.com/motdotla/kibble)
* [flossedtoday](https://github.com/motdotla/flossedtoday)
* [github-streaker](https://github.com/motdotla/github-streaker)
[Create a pull request](https://github.com/scottmotte/dotenv/pulls) and add yours to the list.
[Create a pull request](https://github.com/motdotla/dotenv/pulls) and add yours to the list.

@@ -15,3 +15,3 @@ var assert = require('assert'),

it('version should be set', function() {
result.version.should.eql("0.4.0");
result.version.should.eql("0.5.0");
});

@@ -84,3 +84,3 @@

});
it('ignores commented lines', function() {

@@ -97,3 +97,3 @@ should.not.exist(process.env.COMMENTS);

});
it ('retains inner quotes', function() {

@@ -104,3 +104,13 @@ process.env.RETAIN_INNER_QUOTES.should.eql('{"foo": "bar"}');

it('should return true if .env file exists', function() {
result.load().should.eql(true);
});
it('should return false if .env file does not exists', function() {
var tmp = process.env.NODE_ENV;
process.env.NODE_ENV = 'DNE';
result.load().should.eql(false);
process.env.NODE_ENV = tmp; // reset for future tests
});
});

@@ -107,0 +117,0 @@

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