diff --git a/lib/index.js b/lib/index.js index 7056641..59196d9 100644 --- a/lib/index.js +++ b/lib/index.js @@ -121,7 +121,7 @@ function generateRequireInfo (moduleId) { moduleId: moduleId, callingFile: callingFile, native: native, - extname: path.extname(absPath), + extname: absPath? path.extname(absPath): '', thirdParty: thirdParty, absPath: absPath, absPathResolvedCorrectly: absPathResolvedCorrectly, diff --git a/test/test.js b/test/test.js index dd9f08e..058ecd6 100644 --- a/test/test.js +++ b/test/test.js @@ -88,6 +88,14 @@ describe("intercept-require", function () { restore(); }); + it("should not throw on native modules", function () { + const restore = intercept(() => {}); + expect(function() { + require('fs'); + }).toNotThrow(); + restore(); + }); + it("passes the result and some info to the listener", function () { let calc, result, info; function listener (r, i) {