-
-
Notifications
You must be signed in to change notification settings - Fork 230
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
Fix hook runInThisContext #99
Conversation
Hook runInThisContext with options as parameter instead of filename Hook on require and hook on runInThisContext can not be activated at the same time because require call runInThisContex
Unit test on check coverage used the hook on runInThisContext that is not the default behaviour
Build is Ok with NodeJs 6 but a unit test fail in Node JS 4 |
@CodeTroopers it looks like you and @pangrr are working towards the same goal? (hooking I'm leaning towards @pangrr's implementation; I think that adding this as a new method (rather than modifying old methods) is better, as it provides more backwards compatibility. Perhaps you could pitch in and help test @pangrr's pull so we can see it over the finish line? Or perhaps I'm missing a nuance around the work you're both doing? |
I will agree with you if it was the same function. But @pangrr try to hook And my modification is in theory very basic : replace the hook of |
@pangrr mind helping out with the code review, I haven't used Node's @CodeTroopers @pangrr my biggest immediate question is why we're retiring the |
Ok, I didn't see that |
The failing test happened at this assert: coverageMap[path.resolve(codeRoot, 'context.js')] is undefined. |
@CodeTroopers @pangrr could we work on getting this over the finish line? I'm not experienced with the |
@bcoe could you explain us wat is the purpose of the Another thing, since |
@CodeTroopers, @bcoe, @pangrr what's the progress of this PR and what's left to do? I need this for the referenced ticket in meteor-coverage ... If you tell me what's missing in order to get this merged, I might be able to sit down and get into finding a good way of solving it. |
@SimonSimCity Programmatically the PR work but unit test fails with NodeJs 4 and pass with NodeJs 6 due to internal change of |
@SimonSimCity @CodeTroopers I would love help seeing this over the finish line. My main concern with the existing implementation is that it's a breaking API change; switching from an string representing a filename, to an options object. I think this could potentially cause issues for upstream libraries that were using the existing implementation of What I would love to see would be the addition of |
@bcoe it's the case in the modification of 5 Oct
|
The only advantage I see to hooking For
I don't quite follow this issue; haven't dove too deep into this part of the codebase -- is there a bug you see regarding argument count? Mainly, I'd like to try to not change the function signature of anything; unless there's a compelling reason, e.g., we could rewrite thing something like this: runInThisContextTransformer = function (code, options) {
const filename = typeof options === 'string' ? options : options.filename
return instrumenter.instrumentSync(code, filename);
}; and support the old API surface and the new one. I don't actually use |
No bug, just a feeling that the transformer function can not be usefull because it is limited to the current prototype
No, this is not sufficient. Once again the main problem is that if (config.hooks.hookRunInThisContext()) {
- hook.hookRunInThisContext(matchFn, transformer, hookOpts);
+ hook.hookRunInThisContext(matchFn, runInThisContextTransformer, hookOpts);
+ } else {
+ disabler = hook.hookRequire(matchFn, requireTransformer, hookOpts);
}
- disabler = hook.hookRequire(matchFn, requireTransformer, hookOpts); But with NodeJS 4, |
@CodeTroopers Since this is a change in NodeJS 4 to 6, would it be an option to build in a condition for a specific version of NodeJS? As I understand this, it's a part that goes very much down into how NodeJS is built internally, right? |
@SimonSimCity I added a test on the nodeJS version to add the hook on require when it is needed Now, all tests pass in my environment with NodeJS 4.8.4, NodeJS 6.8.1 and NodeJs 8.9.0.
Must I commit package-lock.json? i 'm not sure... |
Hope you had a good time off keyboard by celebrating 🎅 and 🎆 - and I just wanted to bring this up on the table again ... @bcoe @CodeTroopers I was able to make the package The requirement of a change here though to me makes quite much sense, because the way of calling the method Leaving the code like this is fine for me, because if you have done this wrong, you've probably for a long time not followed the changes on the NodeJS API and have to catch up - and your code anyways wasn't really doing what he was supposed to do 😅 |
@CodeTroopers @bcoe Could you please take a look at this again? I really need it merged ... |
@CodeTroopers mind rebasing with |
@bcoe I rebased with the current master. Like you have removed the NodeJS 4 appveyor build, Do you wish that I remove specific code for NodeJs 4 support? (NodeJS 4 end support is in April) |
@bcoe Any chance we can get this through before the end of this month? |
Friendly ping |
Fix #89
Hook runInThisContext with options as parameter instead of filename
Hook on require and hook on runInThisContext can not be activated at the same time because require call runInThisContext