Skip to content

Commit

Permalink
Merge pull request #291 from sloria/skip-nonenvar-lines
Browse files Browse the repository at this point in the history
Skip over lines that don't set an envvars
  • Loading branch information
jonmagic authored Apr 13, 2018
2 parents 22cfc3f + 697865b commit b44474f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions lib/dotenv/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ def parse_line(line)
if variable_not_set?(line)
raise FormatError, "Line #{line.inspect} has an unset variable"
end
elsif line !~ /\A\s*(?:#.*)?\z/ # not comment or blank line
raise FormatError, "Line #{line.inspect} doesn't match format"
end
end

Expand Down
4 changes: 2 additions & 2 deletions spec/dotenv/parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ def env(string)
expect(env("foo=bar ")).to eql("foo" => "bar") # not 'bar '
end

it "throws an error if line format is incorrect" do
expect { env("lol$wut") }.to raise_error(Dotenv::FormatError)
it "ignores lines that are not variable assignments" do
expect(env("lol$wut")).to eql({})
end

it "ignores empty lines" do
Expand Down

0 comments on commit b44474f

Please sign in to comment.