Skip to content

Commit

Permalink
add debug option (#339)
Browse files Browse the repository at this point in the history
* add debug option to config and parse

* cleanup switch from warn to debug

* console.debug is node v8 and above

* replace quasi-jsdoc with flow

* standard should ignore flow-typed files
  • Loading branch information
maxbeatty committed Oct 7, 2018
1 parent 0fe6114 commit 3e3efc8
Show file tree
Hide file tree
Showing 14 changed files with 677 additions and 57 deletions.
23 changes: 23 additions & 0 deletions .flowconfig
@@ -0,0 +1,23 @@
[ignore]

[include]

[libs]

[lints]
all=warn

[options]
emoji=true
include_warnings=true

[strict]
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.82.0
8 changes: 1 addition & 7 deletions .gitignore
@@ -1,13 +1,7 @@
# Coverage directory used by tools like istanbul
coverage
# Coverage directory
.nyc_output

# Dependency directory
# Commenting this out is preferred by some people, see
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
node_modules

# Users Environment Variables
.lock-wscript

.DS_Store
28 changes: 27 additions & 1 deletion README.md
Expand Up @@ -91,7 +91,7 @@ You can additionally, pass options to `config`.

Default: `path.resolve(process.cwd(), '.env')`

You can specify a custom path if your file containing environment variables is
You may specify a custom path if your file containing environment variables is
named or located differently.

```js
Expand All @@ -109,6 +109,16 @@ using this option.
require('dotenv').config({ encoding: 'base64' })
```

#### Debug

Default: `false`

You may turn on logging to help debug why certain keys or values are not being set as you expect.

```js
require('dotenv').config({ debug: process.env.DEBUG })
```

## Parse

The engine which parses the contents of your file containing environment
Expand All @@ -122,6 +132,22 @@ const config = dotenv.parse(buf) // will return an object
console.log(typeof config, config) // object { BASIC : 'basic' }
```

### Options

#### Debug

Default: `false`

You may turn on logging to help debug why certain keys or values are not being set as you expect.

```js
const dotenv = require('dotenv')
const buf = Buffer.from('hello world')
const opt = { debug: true }
const config = dotenv.parse(buf, opt)
// expect a debug message because the buffer is not in KEY=VAL form
```

### Rules

The parsing engine currently supports the following rules:
Expand Down
2 changes: 2 additions & 0 deletions config.js
@@ -1,3 +1,5 @@
/* @flow */

(function () {
require('./lib/main').config(
require('./lib/cli-options')(process.argv)
Expand Down

0 comments on commit 3e3efc8

Please sign in to comment.