Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support empty lines and comments. #404

Merged
merged 2 commits into from Jan 16, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/main.js
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to influence "debug" behavior, I'd suggest moving closer there instead of possibly altering the parsing logic. if (debug && line.length && line[0] !== '#') might do it, although I have reservations about decreasing debug output.

if (line === '' || line[0] === '#') {
return
}
// matching "KEY' and 'VAL' in 'KEY=VAL'
const keyValueArr = line.match(RE_INI_KEY_VAL)
// matched?
Expand Down