Conversation
| var escape = function(cmd) { | ||
| return '\'' + cmd.replace(/'/g, "'\\''") + '\''; | ||
| if (process.platform === "win32") { | ||
| return '"' + cmd.replace(/"/g, "'") + '"'; |
There was a problem hiding this comment.
Oh, a Windows patch. Cool. 👍
With this regex, though... suppose the content includes a double-quote. Won't this convert it to a single-quote -- and convey different substance? I feel like (on at least a few occasions) I've used cv() to call php:eval, and that that requires some of the params to be passed through quite precisely.
I was curious about how one is supposed to escape a string on Windows, and found https://stackoverflow.com/a/31413730/4195300 -- 😱 Maybe we should either:
- Figure out which notation is specifically appropriate for launching PHP subcommands on Windows
- Rework the file so that we don't need to call
serializeArgs()orescape()-- basically replacingexecSync()with execFileSyc(); the latter should bypass escaping issues.
|
Yes normally it's "" or ^, which wasn't working either so it was confusing and it was trial and error that came up with replacing doubles with singles. I don't know why that works. It might be specific to the commands run just for karma. I can take a look at execfile. |
|
Hmm, I used cv php:script and that solves the quoting for the last argument cmd itself but then I still have the same quoting problem calling cv in the first place, i.e. in karma.conf.js So I think to go this route would require putting the entire cv command, including the call to cv itself, in the external file to be executed, so it's getting a bit convoluted so going to park this for today. I also did try something else just to see: Git for windows includes a Git Bash shell, however the nodejs/javascript functions don't seem to care, so the original quoting also doesn't work when run via nodejs invoked from the git for windows bash shell. |
BEFORE: Running "node node_modules\karma\bin\karma start" doesn't work on windows.
AFTER: It works on windows.