-
-
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
fix: source was being instrumented twice, due to upstream fix in ista… #853
Conversation
index.js
Outdated
@@ -312,13 +312,12 @@ NYC.prototype._addHook = function (type) { | |||
} | |||
|
|||
NYC.prototype._wrapRequire = function () { |
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.
Since this is a breaking change do we need to leave the empty _wrapRequire
here? Nothing in nyc
uses it after this patch.
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.
Apparently github won't let me comment on lines you did not modify. For any testing I updated _handleJs
:
NYC.prototype._handleJs = function (code, options) {
if (typeof options != 'object' || typeof options.filename !== 'string') {
throw new TypeError('options.filename must be a string')
}
var filename = options.filename
/* Remaining original function body here.. */
}
No exceptions were detected by npm test
. I don't think the throw new TypeError()
is needed or wanted IRL, path.relative will throw an exception if options.filename is not a string.
package.json
Outdated
"find-cache-dir", | ||
"find-up", | ||
"foreground-child", | ||
"glob", | ||
"istanbul-lib-coverage", | ||
"istanbul-lib-hook", | ||
"istanbul-lib-instrument", |
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 tested removal of this one line, created a tarball locally, pointed a test package.json to the tarball and nvm exec 6 npm install
worked without an issue.
Since this fixes nyc@12 for node@6 should it be done separate (first) so a non-breaking [email protected] can be released? I'll have some additional patches for both nyc and istanbuljs repos which I hope can be considered before next major release just in case any of my changes are semver-major.
test/nyc-bin.js
Outdated
@@ -570,7 +570,7 @@ describe('the nyc cli', function () { | |||
|
|||
describe('hooks', function () { | |||
it('provides coverage for requireJS and AMD modules', function (done) { | |||
var args = [bin, process.execPath, './index.js'] | |||
var args = [bin, '--hook-run-in-this-context', process.execPath, './index.js'] |
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.
This test still failed for me. I had to also add the argument '--hook-require=false'
for this test to pass.
…nbul-lib-instrument BREAKING CHANGE: --hook-run-in-context, and --hook-run-in-this-context are no longer true by default (they should be enabled if you're using a library like requirejs).
1e0ce84
to
64eeed2
Compare
@coreyfarrell I believe I've addressed your review. Mind verifying that everything works for you as expected? any other changes you think we'll need to make to address your issue? |
@bcoe the only thing remaining to make this compatible with istanbul-lib-hook@next is to take the options argument at One thing I just noticed the PR title and commit message are inaccurate, it's actually a change in [email protected] (still |
@coreyfarrell if you go ahead and get everything working appropriately, we can change the tag on |
@bcoe I've posted istanbuljs/istanbuljs#180 and #855. The nyc test fails in CI due to not testing against my istanbuljs PR. My PR's don't bump the version of any packages since you do that in separate 'publish' commits. I think the istanbuljs dependencies will need to be updated to point to latest next once a new publish is performed, then I can update my nyc PR to require those updated istanbuljs versions and it'll pass the tests (though admittedly I've never tested with appveyor so I don't know what's going on there). |
@coreyfarrell this is now published to |
Seems to work for me. I verified |
BREAKING CHANGE: --hook-run-in-context, and --hook-run-in-this-context are no longer true by default (they should be enabled if you're using a library like requirejs).
see: istanbuljs/istanbuljs#179, #852
CC: @coreyfarrell