Skip to content

Commit b70fdc0

Browse files
committed
Improve shebang test
1 parent 0584c53 commit b70fdc0

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/moduleEnv.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ var moduleWrapper0 = Module.wrapper[0],
4444
// Test the regular expresssion at https://regex101.com/r/dvnZPv/2 and also check out testLib/constModule.js.
4545
matchConst = /(^|\s|\}|;)const(\/\*|\s|{)/gm,
4646
// Required for importing modules with shebang declarations, since NodeJS 12.16.0
47-
shebang = /^(#!).+/,
47+
shebang = /^#!.+/,
4848
nodeRequire,
4949
currentModule;
5050

testLib/sharedTestCases.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,8 +409,10 @@ module.exports = function () {
409409
});
410410

411411
it("should be possible to rewire shebang modules", function () {
412-
expect(function () {
413-
rewire("./shebangModule");
414-
}).to.not.throwError();
412+
var shebangModule = rewire("./shebangModule");
413+
var shebangs = shebangModule.__get__("shebangs");
414+
415+
expect(typeof shebangs).to.be("function");
416+
expect(shebangModule.shebangs()).to.be(true);
415417
});
416418
};

testLib/shebangModule.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ function shebangs() {
44
return true;
55
}
66

7-
module.exports.shebangs = shebangs;
7+
exports.shebangs = shebangs;

0 commit comments

Comments
 (0)