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: v5.0.1
Choose a base ref
...
head repository: motdotla/dotenv
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.0.0
Choose a head ref
  • 3 commits
  • 28 files changed
  • 3 contributors

Commits on Mar 26, 2018

  1. Change in installation cmd (#288)

    * Change in installation command
    yTakkar authored and maxbeatty committed Mar 26, 2018
    Copy the full SHA
    1945a05 View commit details

Commits on Jun 2, 2018

  1. drop support for Node v4 (#304)

    * drop support for Node v4, use node-tap as test runner
    
    * rm examples
    
    * explicitly end async test for cli
    
    * try sync child for windows tests
    
    * extract cli option parsing so it is included in coverage
    
    * add cli option test relating to #306
    
    * Fix tests on Windows by avoiding bug in spawn-wrap by using spawnSync instead of execSync (#307)
    maxbeatty authored Jun 2, 2018
    Copy the full SHA
    d5ff527 View commit details
  2. 6.0.0

    Max Beatty committed Jun 2, 2018
    Copy the full SHA
    740c2f3 View commit details
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Coverage directory used by tools like istanbul
coverage
.nyc_output

# Dependency directory
# Commenting this out is preferred by some people, see
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
coverage/
examples/
.nyc_output/
test/
.editorconfig
.npmignore
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
language: node_js

sudo: false
node_js:
- 4
- 6
- 8
- 9

jobs:
include:
- stage: coverage
node_js: 8
script: npm run ci:coverage
- 10
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -13,7 +13,11 @@ Dotenv is a zero-dependency module that loads environment variables from a `.env
## Install

```bash
npm install dotenv --save
# with npm
npm install dotenv

# or with Yarn
yarn add dotenv
```

## Usage
@@ -113,7 +117,7 @@ an Object with the parsed keys and values.

```js
const dotenv = require('dotenv')
const buf = new Buffer('BASIC=basic')
const buf = Buffer.from('BASIC=basic')
const config = dotenv.parse(buf) // will return an object
console.log(typeof config, config) // object { BASIC : 'basic' }
```
@@ -209,9 +213,9 @@ export const client = new Client(process.env.BEST_API_KEY)

```js
import dotenv from 'dotenv'
dotenv.config()

import errorReporter from './errorReporter'

dotenv.config()
errorReporter.client.report(new Error('faq example'))
```

2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -2,10 +2,10 @@ version: "{build}"
build: off
environment:
matrix:
- nodejs_version: "4"
- nodejs_version: "6"
- nodejs_version: "8"
- nodejs_version: "9"
- nodejs_version: "10"
install:
- ps: Install-Product node $env:nodejs_version
- npm install
12 changes: 3 additions & 9 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
(function () {
var options = {}
process.argv.forEach(function (val, idx, arr) {
var matches = val.match(/^dotenv_config_(.+)=(.+)/)
if (matches) {
options[matches[1]] = matches[2]
}
})

require('./lib/main').config(options)
require('./lib/main').config(
require('./lib/cli-options')(process.argv)
)
})()
1 change: 0 additions & 1 deletion examples/basic/.env

This file was deleted.

3 changes: 0 additions & 3 deletions examples/basic/index.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/es6-preload/.env

This file was deleted.

8 changes: 0 additions & 8 deletions examples/es6-preload/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions examples/es6-preload/run_me

This file was deleted.

1 change: 0 additions & 1 deletion examples/es6/.env

This file was deleted.

10 changes: 0 additions & 10 deletions examples/es6/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions examples/es6/run_me

This file was deleted.

1 change: 0 additions & 1 deletion examples/preload/.env

This file was deleted.

4 changes: 0 additions & 4 deletions examples/preload/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions examples/preload/run_me

This file was deleted.

11 changes: 11 additions & 0 deletions lib/cli-options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const re = /^dotenv_config_(.+)=(.+)/

module.exports = function optionMatcher (args) {
return args.reduce(function (acc, cur) {
const matches = cur.match(re)
if (matches) {
acc[matches[1]] = matches[2]
}
return acc
}, {})
}
4 changes: 1 addition & 3 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

const fs = require('fs')
const path = require('path')

@@ -14,7 +12,7 @@ function parse (src) {
// convert Buffers before splitting into lines and processing
src.toString().split('\n').forEach(function (line) {
// matching "KEY' and 'VAL' in 'KEY=VAL'
const keyValueArr = line.match(/^\s*([\w\.\-]+)\s*=\s*(.*)?\s*$/)
const keyValueArr = line.match(/^\s*([\w.-]+)\s*=\s*(.*)?\s*$/)
// matched?
if (keyValueArr != null) {
const key = keyValueArr[1]
Loading