-
-
Notifications
You must be signed in to change notification settings - Fork 359
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
Upgrade foreground-child, remove unnecessary arg munging #123
Conversation
Foreground-child is now using cross-spawn-async in order to be able to properly spawn shebangs and .cmd/.exe files. This avoids the extra cmd.exe that win-spawn throws into the mix, since that causes problems when there is no PATH environ and a binary is being called explicitly via a full path name. Cross-spawn-async is a lot more code than win-spawn, but the approach it takes is more surgical and well-tested. Because of this, it's no longer necessary to unshift the node/io.js binary onto the argument list when spawning a shebanged javascript file. So, doing 'nyc mocha ...' on Windows will now work, and it's no longer necessary to do 'nyc ./node_modules/mocha/bin/mocha.js ...' or any other extra manual path munging.
LGTM! |
It looks like this might only be part of the solution. I'm getting a diff --git a/bin/nyc.js b/bin/nyc.js
index b63b5ee..0132a79 100755
--- a/bin/nyc.js
+++ b/bin/nyc.js
@@ -122,11 +122,14 @@ if (process.env.NYC_CWD) {
if (argv.all) nyc.addAllFiles()
if (!Array.isArray(argv.require)) argv.require = [argv.require]
- sw([__filename], {
+ var env = {
NYC_CWD: process.cwd(),
- NYC_REQUIRE: argv.require.join(','),
NYC_CACHE: argv.cache ? 'enable' : 'disable'
- })
+ }
+ if (argv.require.length) {
+ env.NYC_REQUIRE = argv.require.join(',')
+ }
+ sw([__filename], env)
foreground(nyc.mungeArgs(argv), function (done) {
if (!argv.silent) report(argv) But now, I get this:
so it looks like it's not properly chopping off the arg when doing |
Your branch works for me (without your diff or any other modification) on Windows 7, with Node // foo.js
var tap = require('tap');
tap.is(1, 1); command:
|
also works when
(only tested that on Node |
Your branch also seems to work just fine when I One thing to note: you want to do |
That |
Switching to just (I do not have I do get a single test failure, but it looks like it is related to newline separators, and occurs when I just run |
@jamestalmage cool, confirmed myself having simply |
Yeah, the I'm most of the way done with making tap's tests all pass (and generate coverage!) on Windows. The hardest one (and where I'm calling it a night) is tap's
If I live for a thousand centuries, I might never forgive Microsoft for their unfathomable continued use of back slashes. |
OK, The following hack to - var spawn = ChildProcess.prototype.spawn
+ var __spawn = ChildProcess.prototype.spawn
+
+ function spawn(options) {
+ console.log('spawn called: ', options.args[3]);
+ options.args[3] = options.args[3].replace('"/bin/sh" ', '')
+ __spawn.apply(this, arguments);
+ } Somehow a |
This was resulting in a opts.require=['undefined'] on Windows.
If you're seeing tap+nyc fail on Windows, can you try this?
That should pull in this nyc PR, plus the windows support I just landed in tap, |
|
I'd argue that the
Then cross-spawn finds that the script does indeed exist, reads the shebang, and tries to execute it as intended. It's only cmd.exe that uses It smells to me like a hacky workaround to specify a test script of |
For discussion, see: istanbuljs/nyc#123 (comment)
Also, spawn-wrap 1.1.1 fixes the failing-to-wrap bug that was the cause for doing |
@isaacs my testing went quite well (I'm quite happy to stop referencing the absolute path to the bin in yargs). Mind rebasing this and we'll land? |
merged in #125 |
merge #123 with master (upgrade foreground-child, spawn-wrap).
Hmm. I didn't realize that. Still, this seems like a potential point of confusion. The error message was particularly unhelpful ("The system could not find the path specified"). My initial assumption on reading that was that it wasn't finding the I'm assuming |
Foreground-child is now using cross-spawn-async in order to be able to
properly spawn shebangs and .cmd/.exe files. This avoids the extra
cmd.exe that win-spawn throws into the mix, since that causes problems
when there is no PATH environ and a binary is being called explicitly
via a full path name.
Cross-spawn-async is a lot more code than win-spawn, but the approach it
takes is more surgical and well-tested.
Because of this, it's no longer necessary to unshift the node/io.js
binary onto the argument list when spawning a shebanged javascript file.
So, doing 'nyc mocha ...' on Windows will now work, and it's no longer
necessary to do 'nyc ./node_modules/mocha/bin/mocha.js ...' or any other
extra manual path munging.