Skip to content

Commit

Permalink
Improve shebang test
Browse files Browse the repository at this point in the history
  • Loading branch information
jhnns committed Dec 18, 2021
1 parent 0584c53 commit b70fdc0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/moduleEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 5 additions & 3 deletions testLib/sharedTestCases.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
};
2 changes: 1 addition & 1 deletion testLib/shebangModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ function shebangs() {
return true;
}

module.exports.shebangs = shebangs;
exports.shebangs = shebangs;

0 comments on commit b70fdc0

Please sign in to comment.