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

handle spaces in the absolute path (#1845) #1847

Merged
merged 11 commits into from
Dec 15, 2021
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