diff --git a/lib/moduleEnv.js b/lib/moduleEnv.js index e5bb2e8..d7657ac 100644 --- a/lib/moduleEnv.js +++ b/lib/moduleEnv.js @@ -44,7 +44,7 @@ var moduleWrapper0 = Module.wrapper[0], // Test the regular expresssion at https://regex101.com/r/dvnZPv/2 and also check out testLib/constModule.js. matchConst = /(^|\s|\}|;)const(\/\*|\s|{)/gm, // Required for importing modules with shebang declarations, since NodeJS 12.16.0 - shebang = /^(#!).+/, + shebang = /^#!.+/, nodeRequire, currentModule; diff --git a/testLib/sharedTestCases.js b/testLib/sharedTestCases.js index 803f59e..0cf9d8b 100644 --- a/testLib/sharedTestCases.js +++ b/testLib/sharedTestCases.js @@ -409,8 +409,10 @@ module.exports = function () { }); it("should be possible to rewire shebang modules", function () { - expect(function () { - rewire("./shebangModule"); - }).to.not.throwError(); + var shebangModule = rewire("./shebangModule"); + var shebangs = shebangModule.__get__("shebangs"); + + expect(typeof shebangs).to.be("function"); + expect(shebangModule.shebangs()).to.be(true); }); }; diff --git a/testLib/shebangModule.js b/testLib/shebangModule.js index da6ac74..c273724 100644 --- a/testLib/shebangModule.js +++ b/testLib/shebangModule.js @@ -4,4 +4,4 @@ function shebangs() { return true; } -module.exports.shebangs = shebangs; +exports.shebangs = shebangs;