Skip to content

Commit

Permalink
Merge pull request #259 from grzuy/fix_leading_whitespaces
Browse files Browse the repository at this point in the history
[Fixes #260] Make space trimming consistent for all task arguments
  • Loading branch information
hsbt authored Mar 8, 2018
2 parents d56ee71 + 7175910 commit 55bee9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rake/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def parse_task_string(string) # :nodoc:
args = []

begin
/((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
/\s*((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args

remaining_args = $2
args << $1.gsub(/\\(.)/, '\1')
Expand Down
6 changes: 6 additions & 0 deletions test/test_rake_task_argument_parsing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def test_can_handle_spaces_between_args
assert_equal ["one", "two", "three", "four"], args
end

def test_can_handle_spaces_between_all_args
name, args = @app.parse_task_string("name[ one , two ,\tthree , \tfour ]")
assert_equal "name", name
assert_equal ["one", "two", "three", "four"], args
end

def test_keeps_embedded_spaces
name, args = @app.parse_task_string("name[a one ana, two]")
assert_equal "name", name
Expand Down

0 comments on commit 55bee9a

Please sign in to comment.