-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
support escaped spaces in cli options #1774
Conversation
I'm unclear why you can't just use double-quotes? Anyway, this looks ok to me. |
@@ -22,9 +22,10 @@ function getOptions() { | |||
try { | |||
var opts = fs.readFileSync(optsPath, 'utf8') | |||
.trim() | |||
.replace(/\\\s+/, '%20') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The
+
would turn an escaped space followed by one or multiple unescaped spaces into a single'%20'
. - The lack of a
//g
flag would make this regex only transform the first escaped whitespace and leave all others
E.g.:
"foo bar\\ \\ baz\\ boo".replace(/\\\s+/, '%20')
"foo bar%20\ baz\ boo"
I agree, I would always go for quoting as well. On the other hand, supporting escaped whitespaces is pretty standard as well, so why not ;)
It looks pretty broken to me 😛 |
@@ -22,9 +22,10 @@ function getOptions() { | |||
try { | |||
var opts = fs.readFileSync(optsPath, 'utf8') | |||
.trim() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the string ends with "\\ "
trim will remove the trailing space. Edge case, I admit, but these two lines should be swapped.
And this is why I shouldn't code late at night. 😜 Thanks for the feedback, I'll fix it. |
0891077
to
d8873c7
Compare
Made the changes and cleaned up the history. |
👍 thanks! |
support escaped spaces in cli options
The current parsing of options does not allow spaces within an option so this fixes that. This is particularly useful in the case of reporter options where a custom reporter may want to accept a string option that contains a space.
See adamgruber/mochawesome#20 for an example.
This patch would require any spaces to be escaped like
--option option\ with\ spaces