-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Bugfix: for whitespace in homedir paths #98
Bugfix: for whitespace in homedir paths #98
Conversation
… in powershell and cmd.
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.
CC @demurgos
test/basic.js
Outdated
@@ -228,6 +228,31 @@ t.test('exec execPath', function (t) { | |||
}) | |||
}) | |||
|
|||
t.test('spaces in path on windows', { skip: !IS_WINDOWS }, function(t) { |
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 don't really have access to Windows, can you confirm that this test fails without the change in lib/mungers/cmd.js
?
The change looks good enough to support spaces. I'll run tests on Windows. |
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 believe that test does not correspond to the code change. The code adds support for shim dirs with spaces (shim dir = home dir by default). The test checks support for node binaries in a path with spaces, but it still uses the home dir. I believe the test should instead spawn the subprocess with SPAWN_WRAP_SHIM_ROOT
set to dir
.
Could you check it and fix it?
The file |
I confirm that I managed to reproduce an issue fixed by this PR: using What I recommend for the test: use a separate script, create a temporary directory with a space, spawn a sub-script (or itself, check how the existing files are structured) with Edit: A simpler test would be a unit-test based off #99 that only checks |
I don't think that distinction matters in this case, as all three variables (my test's node binary path with spaces, SPAWN_WRAP_SHIM_ROOT, and os.homedir) are passed into cp.exec at the same argument index. os.homedir / SHIM_ROOT:
my unit test:
We're only concerned about the first "argument" in the last index of the spawnargs array getting wrapped in quotes. Before my fix, both failed because of the space in my user name and the space in the node.exe path, and after my fix both succeed. Granted, my test only checks the latter scenario but the mungeCmd logic gets invoked after the Please let me know if I'm missing something as a result of my admittedly brief review of the code base. If you are concerned about future proofing the logic I would be ok with adding a legit "unit" test to mungeCmd that ensures quotes are wrapped around the first argument. But otherwise I think the SHIM_ROOT-specific test would ultimately just duplicate the work of this test without any testing benefit. |
Yeah, I didn't need to change that side of the if-branch as it was already properly quoted. I presumed there was already a test somewhere that covered that. But there is a potential conflict with that logic and another test that tries to invoke a node binary renamed to something else. I posted about it here but it didn't get much traction: https://node-tooling.slack.com/archives/C6FL6C221/p1561761510098800 |
…apped npm calls on windows.
@MarcusPope I saw that you sent some changes, is the PR ready? |
@demurgos Yup, it's ready for merge. |
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 fix was simple but the test required more work: good job. I am OK to merge.
@MarcusPope @demurgos thanks for this contribution! |
Fixes istanbuljs/nyc#784
Tested on windows 10 in powershell and cmd.