-
Notifications
You must be signed in to change notification settings - Fork 244
Conversation
So it does not rely on quotation logic to pass.
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.
This looks good, but I'm not certain. Perhaps someone could publish a temporary scoped package of this or something and have people test it out? I just want to be sure this will solve the problems we found before we release a new breaking version!
Thanks so much for this @hgwood!
src/index.js
Outdated
commandArgs.map(commandConvert), | ||
commandArgs | ||
.map(commandConvert) | ||
.map(arg => arg.match(/[ "']/) ? JSON.stringify(arg) : arg), |
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.
I extracted this into a function but forgot to push. Pending.
env: process.env, | ||
}, | ||
) | ||
}) |
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.
I need to add a case where the command itself has spaces. It shouldn't be quoted. Also a case where the command has quotes. I need to verify would the outcome should be.
Codecov Report
@@ Coverage Diff @@
## master #102 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 3 3
Lines 42 43 +1
=====================================
+ Hits 42 43 +1
Continue to review full report at Codecov.
|
This is published as |
Looking back at #100, I'm having doubts. The command there is (ignoring env setters) |
Maybe we should not use the |
I'm kinda thinking that as well @hgwood... So how can we solve the original problem? Should we use a different package to spawn our commands? |
I need to investigate more but I'm guessing the reason cross-spawn can't do what we want (that is, quoted scripts) is because it escapes "dangerous" commands. "dangerous" is defined as not matching |
I don't know :-/ |
Possibly interesting. It says |
Or maybe the |
Yeah, definitely don't want to use |
I have looked at the spawn-command code and as far as I can tell it does the same thing as the |
Here is how I see it right now. As the user of cross-env, I want one of two things.
When I say "command" here, I'm excluding arguments. For example:
If I'm correct, what cross-env should do is enable |
Maybe cross-env could have 2 bins? One for each case. That would let the user decide and cross-env would not have to guess (and potentially fail). |
Having 2 bins would also avoid the breaking change :). The |
I like the idea of 2 bins. But I want to preserve the original use-case with the main bin:
So, as long as we can preserve that then I'm good. |
Just to be sure we're on the same page, this particular use case would work with both bins. Differences show up only when there are escape sequences or quotes. I agree the "right" thing would be to have to main bin do the v3 behavior and to other one the v4. What I was afraid of is that some users that have or will upgrade to v4 by changing their scripts, then will discover they have to revert everything for v5, but actually they would "just" have to use the other bin. Still a bit annoying. To avoid this situation, I suggest that we deprecate v4 on npm so that people don't upgrade to it and wait for v5. What do you think? |
Closed in favor of #104 |
JSON.stringify
does the job of quoting and escaping. What do you think? Please submit any case you might think of.ping @ebriand