Skip to content

Commit

Permalink
Handle blank lines and comments in procfiles (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewmcgarvey authored Oct 4, 2022
1 parent cf26795 commit a6c7782
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions spec/nox/procfile_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,23 @@ Spectator.describe Nox::Procfile do
procfile_entry("frontend", "yarn start")
)
end

it "handles spaces and comments in various places" do
content = <<-PROCFILE
web: crystal src/app.cr
# comment!
frontend: yarn start
PROCFILE

result = Nox::Procfile.parse(content)

expect(result.entries).to contain_exactly(
procfile_entry("web", "crystal src/app.cr"),
procfile_entry("frontend", "yarn start")
)
end
end
end
4 changes: 3 additions & 1 deletion src/nox/procfile.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ struct Nox::Procfile
def self.parse(content : String) : self
proc_file = new
content.each_line do |line|
match_data = ENTRY_REGEX.match(line).not_nil!
match_data = ENTRY_REGEX.match(line)
next if match_data.nil?

proc_file.entries << Nox::Procfile::Entry.new(match_data[1], match_data[2])
end
proc_file
Expand Down

0 comments on commit a6c7782

Please sign in to comment.