Skip to content

Commit

Permalink
drop support for Node v4 (#304)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
maxbeatty authored Jun 2, 2018
1 parent 1945a05 commit d5ff527
Show file tree
Hide file tree
Showing 28 changed files with 4,683 additions and 3,512 deletions.
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
Expand Down
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
Expand Down
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,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' }
```
Expand Down Expand Up @@ -213,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'))
```

Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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')

Expand All @@ -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]
Expand Down
Loading

0 comments on commit d5ff527

Please sign in to comment.