Skip to content

Commit 78a7dc2

Browse files
Evan Lucasbnoordhuis
Evan Lucas
authored andcommitted
module: fix regression in require ../
Fixes regression in require system that prevented loading relative packages via main property in package.json where the file is not index.{ext}. The regression was introduced in commit 36777d2. PR-URL: #145 Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 0fbe528 commit 78a7dc2

File tree

5 files changed

+14
-0
lines changed

5 files changed

+14
-0
lines changed

lib/module.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ Module._findPath = function(request, paths) {
186186
}
187187
}
188188

189+
if (!filename) {
190+
filename = tryPackage(basePath, exts);
191+
}
192+
189193
if (!filename) {
190194
// try it with each of the extensions at "index"
191195
filename = tryExtensions(path.resolve(basePath, 'index'), exts);

test/fixtures/require-bin/bin/req.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../');

test/fixtures/require-bin/lib/req.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = '';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"name": "req",
3+
"main": "./lib/req.js"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
var common = require('../common');
2+
var assert = require('assert');
3+
4+
require(common.fixturesDir + '/require-bin/bin/req.js');

0 commit comments

Comments
 (0)