Skip to content

Conversation

@rikkertkoppes
Copy link

The intercept fails for native modules in node6. In that case. absPath remains undefined, which causes path.extname to fail in node 6, as it no longer accepts undefined.

The behavior of path.extname in node 4 when undefined is passed in is to return an empty string, so the fix is to check for undefined and return an empty string directly if it is.

These are the relevant lines: https://github.com/nickb1080/intercept-require/blob/master/lib/index.js#L108-L130

The error is easy to reproduce, use n to easily switch between node versions. I added a test as well. To reproduce, first merge my first commit, run the test under node 6 and see it fail. Then merge the second commit and see it pass.

@bttmly
Copy link
Owner

bttmly commented Dec 12, 2016

Whoops I had just run into this a couple days ago and fixed it, and published to npm (1.1.0) but forgot to push to GitHub! The relevant fix is mostly https://github.com/nickb1080/intercept-require/blob/master/lib/index.js#L124

Does this fix satisfy your issue? I've pulled your test case in and it passes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants