Skip to content

Commit

Permalink
Support empty lines and comments.
Browse files Browse the repository at this point in the history
In debug mode, show errors like:
```
[dotenv][DEBUG] did not match key and value when parsing line <n>:
[dotenv][DEBUG] did not match key and value when parsing line <n>: #<COMMENTED_LINE>
```
Sometimes we need to add empty lines to separate groups of variables, or comment some of them.
We don't want the debugger or the parser catch them.
  • Loading branch information
wffranco committed Jun 18, 2019
1 parent eba176b commit e918cf3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ function parse (src /*: string | Buffer */, options /*: ?DotenvParseOptions */)

// convert Buffers before splitting into lines and processing
src.toString().split(NEWLINE).forEach(function (line, idx) {
line = line.trim()
// ignore empty and commented lines
if (line === '' || line[0] === '#') {
return
}
// matching "KEY' and 'VAL' in 'KEY=VAL'
const keyValueArr = line.match(RE_INI_KEY_VAL)
// matched?
Expand Down

0 comments on commit e918cf3

Please sign in to comment.