Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: motdotla/dotenv
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.0.0
Choose a base ref
...
head repository: motdotla/dotenv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.1.0
Choose a head ref
  • 6 commits
  • 4 files changed
  • 5 contributors

Commits on Mar 14, 2015

  1. Copy the full SHA
    d871ad2 View commit details
  2. Copy the full SHA
    792fc17 View commit details

Commits on Mar 16, 2015

  1. Merge pull request #56 from matiassingers/patch-1

    Standardise badges in README
    jcblw committed Mar 16, 2015
    Copy the full SHA
    6f6803d View commit details

Commits on Mar 31, 2015

  1. add option to silence errors

    Max Beatty committed Mar 31, 2015
    Copy the full SHA
    4a5be1c View commit details

Commits on Apr 1, 2015

  1. Merge pull request #62 from motdotla/silent-errors

    add option to silence errors
    jcblw committed Apr 1, 2015
    Copy the full SHA
    72e919f View commit details
  2. bumping version

    Jacob Lowe committed Apr 1, 2015
    Copy the full SHA
    d2c81b6 View commit details
Showing with 20 additions and 4 deletions.
  1. +3 −2 README.md
  2. +7 −1 lib/main.js
  3. +1 −1 package.json
  4. +9 −0 test/main.js
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@

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)
[![BuildStatus](https://img.shields.io/travis/motdotla/dotenv.svg?style=flat-square)](https://travis-ci.org/motdotla/dotenv)
[![NPM version](https://img.shields.io/npm/v/dotenv.svg?style=flat-square)](https://www.npmjs.com/package/dotenv)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard)

> "Storing [configuration in the environment](http://www.12factor.net/config)
> is one of the tenets of a [twelve-factor app](http://www.12factor.net/).
8 changes: 7 additions & 1 deletion lib/main.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@ module.exports = {
config: function (options) {
var path = '.env'
var encoding = 'utf8'
var silent = false

if (options) {
if (options.path) {
@@ -19,6 +20,9 @@ module.exports = {
if (options.encoding) {
encoding = options.encoding
}
if (options.silent) {
silent = options.silent
}
}

try {
@@ -31,7 +35,9 @@ module.exports = {

return true
} catch(e) {
console.error(e)
if (!silent) {
console.error(e)
}
return false
}
},
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dotenv",
"version": "1.0.0",
"version": "1.1.0",
"description": "Loads environment variables from .env file",
"main": "lib/main.js",
"scripts": {
9 changes: 9 additions & 0 deletions test/main.js
Original file line number Diff line number Diff line change
@@ -83,6 +83,15 @@ describe('dotenv', function () {
done()
})

it('takes option for silencing errors', function (done) {
var errorStub = s.stub(console, 'error')
readFileSyncStub.throws()

dotenv.config({silent: true}).should.eql(false)
errorStub.called.should.be.false
done()
})

})

describe('parse', function () {