Skip to content

Commit f49d320

Browse files
eoolamattwynneblaisepDane Parchmentaslakhellesoy
authored
handle spaces in the absolute path (#1845) (#1847)
* 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 <[email protected]> Co-authored-by: Blaise Pabon <[email protected]> Co-authored-by: Dane Parchment <[email protected]> * 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 <[email protected]> Co-authored-by: Blaise Pabon <[email protected]> Co-authored-by: Dane Parchment <[email protected]> Co-authored-by: Aslak Hellesøy <[email protected]>
1 parent 6589290 commit f49d320

File tree

4 files changed

+9
-1
lines changed

4 files changed

+9
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Please see [CONTRIBUTING.md](https://github.com/cucumber/cucumber/blob/master/CO
99

1010
## [Unreleased]
1111
### Fixed
12+
- Handles spaces in paths for developers working on cucumbers's own code ([#1845](https://github.com/cucumber/cucumber-js/issues/1845))
1213
- Ensure package.json can be imported by consuming projects
1314
([PR#1870](https://github.com/cucumber/cucumber-js/pull/1870)
1415
[Issue#1869](https://github.com/cucumber/cucumber-js/issues/1869))

features/formatter_paths.feature

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Feature: Formatter Paths
2525

2626
Scenario: Absolute path
2727
Given "{{{tmpDir}}}" is an absolute path
28-
When I run cucumber-js with `-f summary:{{{tmpDir}}}/summary.txt`
28+
When I run cucumber-js with `-f summary:"{{{tmpDir}}}/summary.txt"`
2929
Then the file "{{{tmpDir}}}/summary.txt" has the text:
3030
"""
3131
1 scenario (1 passed)

src/cli/option_splitter.ts

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const OptionSplitter = {
22
split(option: string): string[] {
3+
option = option.replace(/"/g, '')
4+
35
const parts = option.split(/([^A-Z]):(?!\\)/)
46

57
const result = parts.reduce((memo: string[], part: string, i: number) => {

src/cli/option_splitter_spec.ts

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ describe('OptionSplitter', () => {
1919
input: '/custom/formatter:/formatter/output.txt',
2020
output: ['/custom/formatter', '/formatter/output.txt'],
2121
},
22+
{
23+
description: 'splits paths with quotes around them',
24+
input: '/custom/formatter:"/formatter directory/output.txt"',
25+
output: ['/custom/formatter', '/formatter directory/output.txt'],
26+
},
2227
{
2328
description: 'splits absolute windows paths',
2429
input: 'C:\\custom\\formatter:C:\\formatter\\output.txt',

0 commit comments

Comments
 (0)