You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running nyc using Node 7.10.0, my code should be able to spawn() Node.js 6.9.5 executable.
Observed Behavior
All spawned Node.js versions use whatever version is running nyc. In other words, the spawned subprocess always uses process.execPath instead of the original filename to execute.
Bonus Points! Code (or Repository) that Reproduces Issue
Assuming you have 2 different Node.js executables, the versions displayed should differ.
Forensic Information
Operating System: macOS 10.12.5 Environment Information: Node.js 7.10.0 and 6.9.5. NPM version is irrelevant.
Root Problem
The bug is in [email protected], the version nyc uses. [email protected] is almost a year old. The latest version 1.3.5, which was published in May 2017, appears to fix this problem. Simply updating to [email protected] will resolve this ticket.
Workaround
In my gulp file, instead of running nyc directly, I run the following bootstrap:
# run-nyc.jsconstfs=require('fs');constModule=require('module');constoriginalLoader=Module._extensions['.js'];constspawnSwapRE=/\/spawn-wrap\/index\.js$/;Module._extensions['.js']=function(module,filename){if(spawnSwapRE.test(filename)){filename=require.resolve('spawn-wrap');module._compile(fs.readFileSync(filename,'UTF-8'),filename);}else{originalLoader(module,filename);}};// remove this file from argvprocess.argv.splice(1,1);// run nycrequire(process.argv[1]);
I found another bug in spawn-wrap when nyc spawns mocha. spawn-wrap attempts to find out if the file being executed is Node.js so it can wrap it. In the case of mocha, it will detect it as a file with a shebang, namely #!/usr/bin/env node. The problem is spawn-wrap will only test the first part #!/usr/bin/env to see if it's Node and in this case it will fail and proceed to spawn mocha without wrapping it. To fix it, simply need to call nyc node mocha <...>. I've filed istanbuljs/spawn-wrap#54 in hopes it may get resolved.
The text was updated successfully, but these errors were encountered:
Expected Behavior
When running
nyc
using Node 7.10.0, my code should be able tospawn()
Node.js 6.9.5 executable.Observed Behavior
All spawned Node.js versions use whatever version is running
nyc
. In other words, the spawned subprocess always usesprocess.execPath
instead of the originalfilename
to execute.Bonus Points! Code (or Repository) that Reproduces Issue
Assuming you have 2 different Node.js executables, the versions displayed should differ.
Forensic Information
Operating System: macOS 10.12.5
Environment Information: Node.js 7.10.0 and 6.9.5. NPM version is irrelevant.
Root Problem
The bug is in
[email protected]
, the versionnyc
uses.[email protected]
is almost a year old. The latest version 1.3.5, which was published in May 2017, appears to fix this problem. Simply updating to[email protected]
will resolve this ticket.Workaround
In my gulp file, instead of running
nyc
directly, I run the following bootstrap:Note
I found another bug in
spawn-wrap
whennyc
spawnsmocha
.spawn-wrap
attempts to find out if the file being executed is Node.js so it can wrap it. In the case ofmocha
, it will detect it as a file with a shebang, namely#!/usr/bin/env node
. The problem isspawn-wrap
will only test the first part#!/usr/bin/env
to see if it's Node and in this case it will fail and proceed to spawnmocha
without wrapping it. To fix it, simply need to callnyc node mocha <...>
. I've filed istanbuljs/spawn-wrap#54 in hopes it may get resolved.The text was updated successfully, but these errors were encountered: