Skip to content

Commit

Permalink
handle spaces in the absolute path (#1845) (#1847)
Browse files Browse the repository at this point in the history
* put quotes around the absolute path (#1845)

added quotes to wrap the path to summary.txt
to ensure that paths containing spaces are read properly

Co-authored-by: Matt Wynne <matt@cucumber.io>
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Dane Parchment <dparchmentjr@gmail.com>

* fix indentations in feature file

* fixed the bug but needs unit testing

* fixed linting

* adds unit testing for handling paths with quotes

* adds the fix to option splitter files

* updated changelog and removed wip tag

Co-authored-by: Matt Wynne <matt@cucumber.io>
Co-authored-by: Blaise Pabon <blaise@gmail.com>
Co-authored-by: Dane Parchment <dparchmentjr@gmail.com>
Co-authored-by: Aslak Hellesøy <1000+aslakhellesoy@users.noreply.github.com>
  • Loading branch information
5 people authored Dec 15, 2021
1 parent 6589290 commit f49d320
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO

## [Unreleased]
### Fixed
- Handles spaces in paths for developers working on cucumbers's own code ([#1845](https://github.com/cucumber/cucumber-js/issues/1845))
- Ensure package.json can be imported by consuming projects
([PR#1870](https://github.com/cucumber/cucumber-js/pull/1870)
[Issue#1869](https://github.com/cucumber/cucumber-js/issues/1869))
Expand Down
2 changes: 1 addition & 1 deletion features/formatter_paths.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Feature: Formatter Paths

Scenario: Absolute path
Given "{{{tmpDir}}}" is an absolute path
When I run cucumber-js with `-f summary:{{{tmpDir}}}/summary.txt`
When I run cucumber-js with `-f summary:"{{{tmpDir}}}/summary.txt"`
Then the file "{{{tmpDir}}}/summary.txt" has the text:
"""
1 scenario (1 passed)
Expand Down
2 changes: 2 additions & 0 deletions src/cli/option_splitter.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const OptionSplitter = {
split(option: string): string[] {
option = option.replace(/"/g, '')

const parts = option.split(/([^A-Z]):(?!\\)/)

const result = parts.reduce((memo: string[], part: string, i: number) => {
Expand Down
5 changes: 5 additions & 0 deletions src/cli/option_splitter_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ describe('OptionSplitter', () => {
input: '/custom/formatter:/formatter/output.txt',
output: ['/custom/formatter', '/formatter/output.txt'],
},
{
description: 'splits paths with quotes around them',
input: '/custom/formatter:"/formatter directory/output.txt"',
output: ['/custom/formatter', '/formatter directory/output.txt'],
},
{
description: 'splits absolute windows paths',
input: 'C:\\custom\\formatter:C:\\formatter\\output.txt',
Expand Down

0 comments on commit f49d320

Please sign in to comment.